Subject: [Boost-bugs] [Boost C++ Libraries] #12974: Log and Asio without defined _WIN32_WINNT
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2017-04-16 13:56:47
#12974: Log and Asio without defined _WIN32_WINNT
-------------------------+------------------------------
Reporter: sobolevsv@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.64.0
Severity: Problem | Keywords: Win10 VC14
-------------------------+------------------------------
platform: Win10, VC14, boost 1.64
Using Log and Asio simultaneously cause link errors depending on order of
includes.
if _WIN32_WINNT not defined and there are several translation units, most
of it use only Log and some use both Log and Asio I get link error
if Log includes come first followed by Asio, building complete
successfull[[BR]]
for example
{{{
#include <boost/log/common.hpp>
#include <boost/log/sources/severity_channel_logger.hpp>
#include <boost/asio.hpp>
}}}
but if Asio include comes before Log includes[[BR]]
for example
{{{
#include <boost/asio.hpp>
#include <boost/log/common.hpp>
#include <boost/log/sources/severity_channel_logger.hpp>
}}}
I get link error:
LNK2038: mismatch detected for 'boost_log_abi': value 'v2s_mt_nt5' doesn't
match value 'v2s_mt_nt6' in gtclient.obj
this message generated by #pragma detect_mismatch in
boost\log\detail\config.hpp :
{{{
#if defined(BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH)
#pragma detect_mismatch("boost_log_abi",
BOOST_PP_STRINGIZE(BOOST_LOG_VERSION_NAMESPACE))
#endif
}}}
it happend becase Log and Asio use different macros to define target
Windows version.[[BR]]
Log use BOOST_USE_WINAPI_VERSION[[BR]]
but Asio use _WIN32_WINNT
in
\boost\asio\detail\config.hpp [[BR]]
Asio checks if _WIN32_WINNT defined.
if not, it defines it
{{{
# define _WIN32_WINNT 0x0501
}}}
BOOST_USE_WINAPI_VERSION defined in
boost\detail\winapi\config.hpp
it depends on _WIN32_WINNT and _MSC_VER
{{{
#if !defined(BOOST_USE_WINAPI_VERSION)
#if defined(_WIN32_WINNT)
#define BOOST_USE_WINAPI_VERSION _WIN32_WINNT
#elif defined(WINVER)
#define BOOST_USE_WINAPI_VERSION WINVER
#else
// By default use Windows Vista API on compilers that support it and XP on
the others
#if (defined(_MSC_VER) && _MSC_VER < 1500) ||
defined(BOOST_WINAPI_IS_MINGW)
#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WINXP
#else
#define BOOST_USE_WINAPI_VERSION BOOST_WINAPI_VERSION_WIN6
#endif
#endif
#endif
}}}
I think this error appeared in boost 1.60 when Log started using
BOOST_USE_WINAPI_VERSION
http://www.boost.org/users/history/version_1_60_0.html
if I define _WIN32_WINNT=0x0A00 in compiler option, there are no link
error with any includes ordering.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12974> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-04-16 13:59:37 UTC