From 42c794ad422865d66d3bdf4b20286f1f83f3cddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Lind=C3=A9n?= Date: Thu, 16 Aug 2018 23:38:02 +0200 Subject: [PATCH 1/2] Add test checking that MPL_ASSERT_MSG works under VC++8 --- test/Jamfile.v2 | 1 + test/assert_vc8.hpp | 28 ++++++++++++++++++++++++++++ test/assert_vc8_p1.cpp | 23 +++++++++++++++++++++++ test/assert_vc8_p2.cpp | 19 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 test/assert_vc8.hpp create mode 100644 test/assert_vc8_p1.cpp create mode 100644 test/assert_vc8_p2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a62a3b6..f345656 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -13,6 +13,7 @@ compile apply_wrap.cpp ; compile arithmetic.cpp ; compile as_sequence.cpp ; compile assert.cpp ; +link assert_vc8_p1.cpp assert_vc8_p2.cpp ; compile at.cpp ; compile back.cpp ; compile bind.cpp ; diff --git a/test/assert_vc8.hpp b/test/assert_vc8.hpp new file mode 100644 index 0000000..f54df0e --- /dev/null +++ b/test/assert_vc8.hpp @@ -0,0 +1,28 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include + +template +bool func() +{ + BOOST_MPL_ASSERT_MSG( + true, + ALWAYS_TRUE, + (T)); + + return true; +} diff --git a/test/assert_vc8_p1.cpp b/test/assert_vc8_p1.cpp new file mode 100644 index 0000000..2883135 --- /dev/null +++ b/test/assert_vc8_p1.cpp @@ -0,0 +1,23 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func(); + +int main() +{ +} diff --git a/test/assert_vc8_p2.cpp b/test/assert_vc8_p2.cpp new file mode 100644 index 0000000..6b53573 --- /dev/null +++ b/test/assert_vc8_p2.cpp @@ -0,0 +1,19 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func(); From e44b2ae761540776f09c83021c11253898029d9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Lind=C3=A9n?= Date: Mon, 13 Aug 2018 20:10:57 +0200 Subject: [PATCH 2/2] Fix BOOST_MPL_ASSERT_MSG for VC++8 The struct member function inside BOOST_MPL_ASSERT_MSG_IMPL was causing multiple definitions of the same symbol when used inside e.g. template functions. An example of where this is a big issue is in the boost/geometry library where you currently only can call each function once for each geometry or you get hit by the multiple definitions linking error. This fix* works around the issue by gracefully degrading to BOOST_STATIC_ASSERT_MSG instead of failing during linking. --- include/boost/mpl/assert.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/boost/mpl/assert.hpp b/include/boost/mpl/assert.hpp index e41b583..baf43e0 100644 --- a/include/boost/mpl/assert.hpp +++ b/include/boost/mpl/assert.hpp @@ -443,8 +443,16 @@ BOOST_MPL_AUX_ASSERT_CONSTANT( \ /**/ #endif -#define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \ +// Work around BOOST_MPL_ASSERT_MSG_IMPL generating multiple definition linker errors on VC++8. +#if defined(BOOST_MSVC) && BOOST_MSVC < 1500 +# include +# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \ +BOOST_STATIC_ASSERT_MSG( c, #msg ) \ +/**/ +#else +# define BOOST_MPL_ASSERT_MSG( c, msg, types_ ) \ BOOST_MPL_ASSERT_MSG_IMPL( BOOST_MPL_AUX_PP_COUNTER(), c, msg, types_ ) \ /**/ +#endif #endif // BOOST_MPL_ASSERT_HPP_INCLUDED