How to check my code if BOOST is enabled?

I want some parts of my code to be included only if boost is installed.

I found this answer and this one . However, they are intended to determine the version of boost.

So would something like this be completely safe?

#if BOOST_VERSION
  // boost code
#endif

If not, how do I do this?

+1
source share
1 answer

You will need to make your own macro to do conditional compilation (or somehow control it with your build system). For instance:

#ifdef MYPROJ_HAS_BOOST
#  include <boost/filesystem.hpp>
#endif

Then compile with -DMYPROJ_HAS_BOOST(or not).

BOOST_VERSION - Boost, , Boost. <boost/version.hpp> , Boost, , , .

#include <boost/version.hpp , ; , Boost .

+4

All Articles