Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio]Winsock.h
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-07-07 20:47:15


On Tue, Jul 7, 2009 at 7:00 PM, Commander Pirx <CmdPirx_at_[hidden]> wrote:

> I was struggling with this problem too. Include <asio.hpp> before
> <windows.h> and all works fine.
>
>
> "Robert Jones" <robertgbjones_at_[hidden]> schrieb im Newsbeitrag
> news:4efd67eb0907070616i225bc2f4h7a4a255be2e8bd5d_at_mail.gmail.com...
>
> On Tue, Jul 7, 2009 at 11:42 AM, Igor R <boost.lists_at_[hidden]> wrote:
>
> What's the deal with Winsock.h & Asio?
>>
>> I can see there's been chatter on this topic before, but not what the
>> result is.
>>
>
>
> Could you please mention your Boost version, compiler and the specific
> issue you encounter?
>
>
> Yeah, sorry, I thought this would instantly ring bells with folks!
>
> Boost 1.38, Vis Studio 2005, and the issue is that unless I put the main
> Boost.Asio header first in my #include list I get a failure message
>
> WinSock.h has already been included
>
> from socket_types.hpp.
>
> Thanks, Rob.
>

I'm not sure what the specific problem is, but this sounds eerily similar to
the issues you encounter when using raw winsock programming without the
presence of asio at all. If it's the problem I'm thinking of, then I'm
pretty sure you can get around it by including <winsock2.h> before including
<windows.h>.

Including asio.h first probably works fine too as others have mentioned, but
I don't always like to include boost header files in my precompiled headers,
especially if most of the logic I'm using from those headers is encapsulated
in one or two specific cpp files.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net