TL;DR
Is it possible to compile Boost.Regex 1.76 in Header Only Mode (non BOOST_REGEX_CXX03 mode) with a C++/CLI i.e. /clr i.e. _MANAGED project?
We have been using Boost.Regex for years in our regular Visual C++ projects. A very few of our projects are compiled with Common Language Runtime Support (/clr) which enables C++/CLI, (and for these we always linked in the boost regex library statically). We always pre-built the boost regex DLL and static lib and then linked these from MSVC.
Now, with Boost 1.76 Boost.Regex newly is header only, unless compiling in C++03 mode.
( Version 1.76.0 ) ...
Regex:
- Regex is now header only except in C++03 mode
- Support for C++03 is now deprecated.
- ...
However, our C++/CLI project will -- through the boost config magic -- automatically select to build Boost.Regex in the C++03 == BOOST_REGEX_CXX03 mode!
- Our current MSVC is Visual Studio 19.7.6,
_MSC_FULL_VER 192729112
Since no longer having to pre-build any Boost.Regex binaries would be quite handy, we're currently looking into whether we can get the C++/CLI project to compile in the non BOOST_REGEX_CXX03 mode:
- Does anybody know how through the magic of boost/config the macro
BOOST_REGEX_CXX03is selected for a C++_MANAGEDproject? (I currently suspect_CPPLIB_VER, but I'm not even sure what version that is.) - Can we switch this? ->
Is it possible to compile Boost.Regex 1.76 in Header Only Mode with a C++/CLI i.e. /clr i.e. _MANAGED project?
To answer the question quickly: No it is not possible to compile Boost.Regex in C++11 mode, that is non C++03 mode with the /clr flag on.
The reason
BOOST_REGEX_CXX03gets selected under/clris thatboost\regex\config.hppwill select it if any of... BOOST_NO_CXX11_HDR_MUTEX ... BOOST_NO_CXX11_HDR_ATOMIC ...are set, and these are set under/clrbecause C++/CLI only supports C++03, or rather it supports all of C++03 whereas e.g.std::mutexis not supported in C++/CLI.As others have written:
So, IFF you need Boost.regex in a translation unit what is compiled
/clr, you must use the C++03 mode.As for the OP problem: Should check whether the given VC++ project that uses C++/CLI really needs to compile all files with /clr on, or maybe the translation units that actually use Boost.Regex are native C++ anyway and could be compiled without /clr and then just linked together with the C++/CLI object files.