[asio] asio compile error in tutorial source under msvc, vs2003 install

I'm trying to compile the asio Daytime.3 tutorial source from http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/tutorial/tutdayti... and I'm getting an type error in an arg passed from asio to winsock. I'm going to try to grok the code in win_iocp_socket_service.hpp to understand the problem, but it's my first look at asio internals. (The tutorial builds correctly on Linux, not surprising as it's a windows specific binding.) Any help or pointers are appreciated: cl -c -nologo -EHsc -GR -Zc:forScope -MT -I/Boost/include/boost-1_33_1/ Daytime3-1.cpp -FoDaytime3-1.obj Daytime3-1.cpp Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000 target) \Boost\include\boost-1_33_1\boost\asio\detail\win_iocp_socket_service.hpp(527) : error C2664: 'WSASend' : cannot convert parameter 6 from 'boost::asio::detail::handler_ptr<Alloc_Traits>::pointer_type' to 'LPWSAOVERLAPPED' with [ Alloc_Traits=alloc_traits ] Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast \Boost\include\boost-1_33_1\boost\asio\stream_socket_service.hpp(222) : see reference to function template instantiation 'void boost::asio::detail::win_iocp_socket_service<Protocol>::async_send<Const_Buffers,Handler>(boost::asio::detail::win_iocp_socket_service<Protocol>::implementation_type &,const Const_Buffers &,boost::asio::socket_base::message_flags,Handler)' being compiled with [ Protocol=boost::asio::ip::tcp, Const_Buffers=boost::asio::const_buffer_container_1, Handler=boost::asio::detail::write_handler<boost::asio::ip::tcp::socket,boost::asio::const_buffer_container_1,boost::asio::detail::transfer_all_t,boost::_bi::bind_t<void,boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>,boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>>> ] \Boost\include\boost-1_33_1\boost\asio\basic_stream_socket.hpp(611) : see reference to function template instantiation 'void boost::asio::stream_socket_service<Protocol>::async_send<Const_Buffers,Handler>(boost::asio::stream_socket_service<Protocol>::implementation_type &,const Const_Buffers &,boost::asio::socket_base::message_flags,Handler)' being compiled with [ Protocol=boost::asio::ip::tcp, Const_Buffers=boost::asio::const_buffer_container_1, Handler=boost::asio::detail::write_handler<boost::asio::ip::tcp::socket,boost::asio::const_buffer_container_1,boost::asio::detail::transfer_all_t,boost::_bi::bind_t<void,boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>,boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>>> ] \Boost\include\boost-1_33_1\boost\asio\impl\write.ipp(167) : see reference to function template instantiation 'void boost::asio::basic_stream_socket<Protocol>::async_write_some<Const_Buffers,boost::asio::detail::write_handler<Async_Write_Stream,Const_Buffers,Completion_Condition,Handler>>(const Const_Buffers &,boost::asio::detail::write_handler<Async_Write_Stream,Const_Buffers,Completion_Condition,Handler>)' being compiled with [ Protocol=boost::asio::ip::tcp, Const_Buffers=boost::asio::const_buffer_container_1, Async_Write_Stream=boost::asio::ip::tcp::socket, Completion_Condition=boost::asio::detail::transfer_all_t, Handler=boost::_bi::bind_t<void,boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>,boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>> ] \Boost\include\boost-1_33_1\boost\asio\impl\write.ipp(174) : see reference to function template instantiation 'void boost::asio::async_write<Async_Write_Stream,Const_Buffers,boost::asio::detail::transfer_all_t,Handler>(Async_Write_Stream &,const Const_Buffers &,Completion_Condition,Handler)' being compiled with [ Async_Write_Stream=boost::asio::ip::tcp::socket, Const_Buffers=boost::asio::const_buffer_container_1, Handler=boost::_bi::bind_t<void,boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>,boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>>, Completion_Condition=boost::asio::detail::transfer_all_t ] Daytime3-1.cpp(41) : see reference to function template instantiation 'void boost::asio::async_write<boost::asio::ip::tcp::socket,boost::asio::const_buffer_container_1,boost::_bi::bind_t<R,F,L>>(Async_Write_Stream &,const Const_Buffers &,Handler)' being compiled with [ R=void, F=boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>, L=boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>, Async_Write_Stream=boost::asio::ip::tcp::socket, Const_Buffers=boost::asio::const_buffer_container_1, Handler=boost::_bi::bind_t<void,boost::_mfi::mf2<void,tcp_connection,const boost::asio::error &,size_t>,boost::_bi::list3<boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B1,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B2,boost::_bi::list_av_3<boost::shared_ptr<tcp_connection>,boost::arg<1>,boost::arg<2>>::B3>>

Hi Rod, Rod Morison <rod@morison.biz> wrote:
I'm trying to compile the asio Daytime.3 tutorial source from http://asio.sourceforge.net/boost_asio_0_3_7/libs/asio/doc/tutorial/tutdayti... and I'm getting an type error in an arg passed from asio to winsock. I'm going to try to grok the code in win_iocp_socket_service.hpp to understand the problem, but it's my first look at asio internals. (The tutorial builds correctly on Linux, not surprising as it's a windows specific binding.)
Any help or pointers are appreciated:
cl -c -nologo -EHsc -GR -Zc:forScope -MT -I/Boost/include/boost-1_33_1/ Daytime3-1.cpp -FoDaytime3-1.obj
In short, winsock2.h thinks you're compiling for Win16! The quick workaround is to add -DWIN32 to your compiler command line. This has been fixed properly in CVS since asio 0.3.7 was released. It's also not a problem with Platform SDKs that are newer than the one included with VC7.1. Cheers, Chris

Christopher Kohlhoff wrote:
In short, winsock2.h thinks you're compiling for Win16! The quick workaround is to add -DWIN32 to your compiler command line.
Thanks, worked. Great lib, glad to see its adoption. After 20 years of platform dependent socket tweaking asio gets it right without getting into patterns that make too many assumptions. Bravo. (WIN16? Seg'd memory models? Ew, bad flashbacks ;-) )
participants (2)
-
Christopher Kohlhoff
-
Rod Morison