Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with Boost.Asio #179

Closed
Chnossos opened this issue Feb 14, 2016 · 6 comments
Closed

Conflict with Boost.Asio #179

Chnossos opened this issue Feb 14, 2016 · 6 comments

Comments

@Chnossos
Copy link

Hi,

Compiling the following source file with Microsoft Visual C++ 2015 and Boost 1.60.0:

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

displays the following error:

error directive: WinSock.h has already been included (c:\C++\boost\boost_1_60_0\boost\asio\detail\socket_types.hpp:24)

@crackedmind
Copy link

Spdlog don't use winsock librrary. Check that you didn't include Winsock2.h before asio.
Or may be you include windows.h before asio without WIN32_LEAN_AND_MEAN define, that disabled inclusion of winsock.h

@RavenX8
Copy link

RavenX8 commented Mar 21, 2016

I have this same issue. Before I added spdlog, I could compile just fine. After adding the spdlog include file, I keep getting this error. The only way to fix it that I could see was to not use this lib.

@gabime
Copy link
Owner

gabime commented Mar 21, 2016

I will forward this to cppformat lib. seems the file spdlog/details/format.cc includes windows.h without defining WIN32_LEAN_AND_MEAN

@vitaut
Copy link

vitaut commented Mar 21, 2016

As mentioned in fmtlib/fmt#297, I don't think WIN32_LEAN_AND_MEAN should be defined in a header because it can break some users. Since the error is generated by asio which wants to include winsock.h first, I think a better solution is to reorder the includes:

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

This requirement should probably be documented in Boost asio somewhere.

gabime added a commit that referenced this issue Mar 21, 2016
…OWS_H=0 in format.h and preventing include of windows.h)
@gabime gabime closed this as completed Mar 21, 2016
@gabime
Copy link
Owner

gabime commented Mar 21, 2016

Fixed in 7945136

@gcerretani
Copy link

The same bug reappeared in version v1.6.0.

This source code

#include <spdlog/spdlog.h>
#include <boost/asio.hpp>

compiles in v1.5.0, but fails since v1.6.0 with messages like

fatal error C1189: #error: WinSock.h has already been included.

Tested up to v1.8.0 with Boost v1.67 and MSVC 1900 (2015).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants