[date_time][asio] Compilation errors due to winsock includes

Hi, While trying to resolve a Interprocess error when using it with asio, I've found that the problem is caused because Interprocess uses date_time. If you compile: #include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/asio/asio.hpp> int main() { return 0; } You get a lot of socket redefinitions because date_time seems to be including winsock.h whereas asio uses winsock2.h. Is there any way to avoid these errors? Regards, Ion

Hi Ion, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
If you compile:
#include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/asio/asio.hpp>
int main() { return 0; }
You get a lot of socket redefinitions because date_time seems to be including winsock.h whereas asio uses winsock2.h.
Yep, date_time is including windows.h, which includes winsock.h.
Is there any way to avoid these errors?
You can reverse the inclusion order to make it work. Defining WIN32_LEAN_AND_MEAN will also prevent windows.h from including winsock.h. The asio headers already include the following construct to #define WIN32_LEAN_AND_MEAN: # if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) # if !defined(WIN32_LEAN_AND_MEAN) # define WIN32_LEAN_AND_MEAN # endif // !defined(WIN32_LEAN_AND_MEAN) # endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) Perhaps something similar should be added to date_time, since it does not need winsock.h? Cheers, Chris

Hi Christopher,
You can reverse the inclusion order to make it work.
But this is very annoying since headers from every boost library using date-time would have also those dependencies.
Defining WIN32_LEAN_AND_MEAN will also prevent windows.h from including winsock.h. The asio headers already include the following construct to #define WIN32_LEAN_AND_MEAN:
# if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) # if !defined(WIN32_LEAN_AND_MEAN) # define WIN32_LEAN_AND_MEAN # endif // !defined(WIN32_LEAN_AND_MEAN) # endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
Perhaps something similar should be added to date_time, since it does not need winsock.h?
Seems the most reasonable answer, if lean and mean configuration has all the necessary headers Boost.DateTime needs. Regards, Ion

On Sun, 24 Sep 2006 19:52:29 +0200, Ion Gaztañaga wrote
Hi Christopher,
You can reverse the inclusion order to make it work.
But this is very annoying since headers from every boost library using date-time would have also those dependencies.
Defining WIN32_LEAN_AND_MEAN will also prevent windows.h from including winsock.h. The asio headers already include the following construct to #define WIN32_LEAN_AND_MEAN:
# if !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN) # if !defined(WIN32_LEAN_AND_MEAN) # define WIN32_LEAN_AND_MEAN # endif // !defined(WIN32_LEAN_AND_MEAN) # endif // !defined(BOOST_ASIO_NO_WIN32_LEAN_AND_MEAN)
Perhaps something similar should be added to date_time, since it does not need winsock.h?
Seems the most reasonable answer, if lean and mean configuration has all the necessary headers Boost.DateTime needs.
The include is for the 'FILETIME' functions. Looking again at MSDN it appears that it is declared in Winbase.h -- I wonder if we could include that instead? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas... Otherwise, I'm fine adding macros to make this work. Jeff

Jeff Garland wrote:
The include is for the 'FILETIME' functions. Looking again at MSDN it appears that it is declared in Winbase.h -- I wonder if we could include that instead?
On at least some Windows-like platforms (namely Windows Mobile 5) including anything like winbase.h directly blows up as configuration macros are not defined properly unless winbase.h is included from windows.h So I vote for WIN32_LEAN_AND_MEAN. Mike
participants (4)
-
Christopher Kohlhoff
-
Ion Gaztañaga
-
Jeff Garland
-
Michael Marcin