Skip to content

Instantly share code, notes, and snippets.

@jfalcou
Last active January 26, 2020 14:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfalcou/509783 to your computer and use it in GitHub Desktop.
Save jfalcou/509783 to your computer and use it in GitHub Desktop.
#include "library_mismatch.hpp"
BOOST_USE_LIBRARY_VERSION(foo,FEATURES2)
int foo() {}
#ifndef MISMATCH_HPP
#define MISMATCH_HPP
#include "register.hpp"
#define FEATURES0 with
#if defined(FEATURES_A)
#define FEATURES1 BOOST_PP_CAT(FEATURES0,_A)
#else
#define FEATURES1 FEATURES0
#endif
#if defined(FEATURES_B)
#define FEATURES2 BOOST_PP_CAT(FEATURES1,_B)
#else
#define FEATURES2 FEATURES1
#endif
BOOST_REGISTER_LIBRARY_VERSION(foo,FEATURES2)
int foo();
#endif
#include "library_mismatch.hpp"
#include <cstdio>
int main()
{
printf("%s\n",BOOST_PP_STRINGIZE(FEATURES2));
}
#ifndef BOOST_REGISTER_LIBRARY_HPP
#define BOOST_REGISTER_LIBRARY_HPP
#include <boost/system/config.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/stringize.hpp>
#define BOOST_VERSION_MESSAGE _library_version_mismatch_
#define BOOST_USE_LIBRARY_VERSION(S,V) \
namespace boost { namespace config \
{ \
bool BOOST_SYSTEM_DECL \
BOOST_PP_CAT(S,BOOST_PP_CAT(BOOST_VERSION_MESSAGE,V))() \
{ \
return true; \
} \
} } \
/**/
#define BOOST_REGISTER_LIBRARY_VERSION(S,V) \
namespace boost { namespace config \
{ \
bool BOOST_SYSTEM_DECL \
BOOST_PP_CAT(S,BOOST_PP_CAT(BOOST_VERSION_MESSAGE,V))(); \
bool const BOOST_PP_CAT(check_,BOOST_PP_CAT(S,V)) = \
BOOST_PP_CAT(S,BOOST_PP_CAT(BOOST_VERSION_MESSAGE,V))(); \
} } \
/**/
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment