From 3d6e55bddf6f12dbb2bf0ef634f1b145990854d3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 21 Jul 2022 18:51:54 +0300 Subject: [PATCH] Work around __LINE__ not being constant with /ZI (refs #26) --- include/boost/assert/source_location.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index cca87e7..0d76858 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -152,6 +152,15 @@ template std::basic_ostream & operator<<( std::basic_ost // the correct result under 19.31, so prefer the built-ins # define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN()) +#elif defined(BOOST_MSVC) + +// __LINE__ is not a constant expression under /ZI (edit and continue) for 1925 and before + +# define BOOST_CURRENT_LOCATION_IMPL_1(x) BOOST_CURRENT_LOCATION_IMPL_2(x) +# define BOOST_CURRENT_LOCATION_IMPL_2(x) (x##0 / 10) + +# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, BOOST_CURRENT_LOCATION_IMPL_1(__LINE__), "") + #elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L # define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current())