Re: [asio-users] windows.h, winsock.h and winsock2.h?
Brought to you by:
chris_kohlhoff
|
From: Christopher K. <ch...@ko...> - 2007-01-26 22:41:17
|
Hi Olaf, On Thu, 25 Jan 2007 19:02:06 +0100, "Olaf van der Spek" <ola...@gm...> said: > On 1/25/07, Cory Nelson <ph...@gm...> wrote: > > #define WIN32_LEAN_AND_MEAN - it will stop windows.h from including winsock.h > > Why do I have to do that myself? You don't if you include asio.hpp first ;) > IMO asio shouldn't leak anything when I include it's header. This is something I will try to fix in the longer term, but for now including an asio header file is effectively including winsock2.h. For reasons known only to Microsoft, windows.h still wants to include the Winsock version 1 declarations by default, and you can't have both winsock.h and winsock2.h. So for the time being your options are: - Reorder the includes so asio.hpp comes before windows.h - Define WIN32_LEAN_AND_MEAN (which I would recommend doing anyway because it eliminates a lot of useless stuff from windows.h) - Explicitly include winsock2.h before windows.h Cheers, Chris |