boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
422 stars 69 forks source link

"WinSock.h has already been included" #155

Closed radj307 closed 5 months ago

radj307 commented 5 months ago

The order in which you include stacktrace.hpp & asio.hpp can cause a compilation error on Windows.
I tested this on MSVC 19.34.31947 with Boost 1.84.0.

For example, this code doesn't compile:

#include <boost/stacktrace/stacktrace.hpp>
#include <boost/asio.hpp>

This is the error message:

boost\asio\detail\socket_types.hpp(24): fatal error C1189: #error:  WinSock.h has already been included

It compiles fine if you swap the order:

#include <boost/asio.hpp>
#include <boost/stacktrace/stacktrace.hpp>

The same code compiles without issue on Linux (tested with gcc 10 on Debian 11).
This isn't really a huge problem as all you have to do to fix it is include socket_types.hpp before stacktrace.hpp, but the inconsistency is weird when cross-compiling.

apolukhin commented 5 months ago

Let's continue with this problem in https://github.com/chriskohlhoff/asio/issues/1441