WinSock.h has already been included

Hi, Why trying to use the asio library I'm getting the following error (I believe this happens I include <boost/asio.hpp> once): WinSock.h has already been included c:\program files\boost \boost_1_35_0\boost\asio\detail\socket_types.hpp 27 I'm compiling using VS 2008 on WinXP. Any idea how to deal with this? Thanks, Jean

You are probably #including <windows.h> prior to that without defining WIN32_LEAN_AND_MEAN first. On Mon, Jul 7, 2008 at 4:54 PM, Jean-Sebastien Stoezel <js.stoezel@gmail.com> wrote:
Hi,
Why trying to use the asio library I'm getting the following error (I believe this happens I include <boost/asio.hpp> once):
WinSock.h has already been included c:\program files\boost\boost_1_35_0\boost\asio\detail\socket_types.hpp 27
I'm compiling using VS 2008 on WinXP.
Any idea how to deal with this?
Thanks, Jean
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org

Hi, Thanks for your quick answer. I am not including <windows.h> (I'm compiling a console application, without support for MFCs or precompiled headers). Here is what I have defined in the project: WIN32;_DEBUG;_CONSOLE I haven't defined WIN32_LEAN_AND_MEAN or any other macro (just included <boost/asio.hpp>). Any idea of what else this could be? Thanks, Jean On 7-Jul-08, at 8:00 PM, Cory Nelson wrote:
You are probably #including <windows.h> prior to that without defining WIN32_LEAN_AND_MEAN first.
On Mon, Jul 7, 2008 at 4:54 PM, Jean-Sebastien Stoezel <js.stoezel@gmail.com> wrote:
Hi,
Why trying to use the asio library I'm getting the following error (I believe this happens I include <boost/asio.hpp> once):
WinSock.h has already been included c:\program files\boost\boost_1_35_0\boost\asio\detail\socket_types.hpp 27
I'm compiling using VS 2008 on WinXP.
Any idea how to deal with this?
Thanks, Jean
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Jean-Sebastien Stoezel wrote:
Hi,
Thanks for your quick answer. I am not including <windows.h> (I'm compiling a console application, without support for MFCs or precompiled headers). Here is what I have defined in the project: WIN32;_DEBUG;_CONSOLE
I haven't defined WIN32_LEAN_AND_MEAN or any other macro (just included <boost/asio.hpp>).
Any idea of what else this could be?
Thanks, Jean
Hi Are you using Boost date/time anywhere?? There are two includes of windows.h in filetime_functions.hpp and microsec_time_clock.hpp which do not have the "lean and mean" macro defined before the includes. For me, I had to add the "lean and mean" to microsec_time_clock.hpp just prior to the windows.h include to fix this error. Kevin

Hi, Here are the boost header files I include in my application: #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> I guess I am then using the boost date/time. I am not sure I understand what boost macros I need to define and so far I have defined none. Isn't there another way to fix this issue, rather than hacking the boost files? Thanks, Jean On 8-Jul-08, at 12:04 AM, Kevin Scarr wrote:
Jean-Sebastien Stoezel wrote:
Hi, Thanks for your quick answer. I am not including <windows.h> (I'm compiling a console application, without support for MFCs or precompiled headers). Here is what I have defined in the project: WIN32;_DEBUG;_CONSOLE I haven't defined WIN32_LEAN_AND_MEAN or any other macro (just included <boost/asio.hpp>). Any idea of what else this could be? Thanks, Jean
Hi
Are you using Boost date/time anywhere??
There are two includes of windows.h in filetime_functions.hpp and microsec_time_clock.hpp which do not have the "lean and mean" macro defined before the includes.
For me, I had to add the "lean and mean" to microsec_time_clock.hpp just prior to the windows.h include to fix this error.
Kevin
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Jean-Sebastien Stoezel wrote:
Here are the boost header files I include in my application:
#include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
I guess I am then using the boost date/time. I am not sure I understand what boost macros I need to define and so far I have defined none.
Isn't there another way to fix this issue, rather than hacking the boost files?
Add a #define WIN32_LEAN_AND_MEAN or #include <winsock2.h> before including all boost headers. #define WIN32_LEAN_AND_MEAN // #include <winsock2.h> // or this #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp>

If you #include date_time prior to asio and as previously stated: #define WIN32_LEAN_AND_MEAN that should get rid of the errors.. Cheers, Tim On Tue, Jul 8, 2008 at 9:10 AM, gchen <chengang31@gmail.com> wrote:
Jean-Sebastien Stoezel wrote:
Here are the boost header files I include in my application:
#include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
I guess I am then using the boost date/time. I am not sure I understand what boost macros I need to define and so far I have defined none.
Isn't there another way to fix this issue, rather than hacking the boost files?
Add a #define WIN32_LEAN_AND_MEAN or #include <winsock2.h> before including all boost headers.
#define WIN32_LEAN_AND_MEAN // #include <winsock2.h> // or this #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Regards, Timothy St. Clair [timothysc@gmail.com]

Hi, Thanks for the advice, it solved the issue. Jean There is no other include. I still get: On 8-Jul-08, at 9:10 AM, gchen wrote:
Jean-Sebastien Stoezel wrote:
Here are the boost header files I include in my application: #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> I guess I am then using the boost date/time. I am not sure I understand what boost macros I need to define and so far I have defined none. Isn't there another way to fix this issue, rather than hacking the boost files?
Add a #define WIN32_LEAN_AND_MEAN or #include <winsock2.h> before including all boost headers.
#define WIN32_LEAN_AND_MEAN // #include <winsock2.h> // or this #include <boost/thread/thread.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (5)
-
Cory Nelson
-
gchen
-
Jean-Sebastien Stoezel
-
Kevin Scarr
-
Tim St. Clair