Chris@16: // Copyright David Abrahams 2002. Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: #ifndef WORKAROUND_DWA2002126_HPP Chris@16: # define WORKAROUND_DWA2002126_HPP Chris@16: Chris@16: // Compiler/library version workaround macro Chris@16: // Chris@16: // Usage: Chris@16: // Chris@16: // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) Chris@16: // // workaround for eVC4 and VC6 Chris@16: // ... // workaround code here Chris@16: // #endif Chris@16: // Chris@16: // When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the Chris@16: // first argument must be undefined or expand to a numeric Chris@16: // value. The above expands to: Chris@16: // Chris@16: // (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300 Chris@16: // Chris@16: // When used for workarounds that apply to the latest known version Chris@16: // and all earlier versions of a compiler, the following convention Chris@16: // should be observed: Chris@16: // Chris@16: // #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301)) Chris@16: // Chris@16: // The version number in this case corresponds to the last version in Chris@16: // which the workaround was known to have been required. When Chris@16: // BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro Chris@16: // BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates Chris@16: // the workaround for any version of the compiler. When Chris@16: // BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or Chris@16: // error will be issued if the compiler version exceeds the argument Chris@16: // to BOOST_TESTED_AT(). This can be used to locate workarounds which Chris@16: // may be obsoleted by newer versions. Chris@16: Chris@16: # ifndef BOOST_STRICT_CONFIG Chris@16: Chris@16: #include Chris@16: Chris@16: #ifndef __BORLANDC__ Chris@16: #define __BORLANDC___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __BORLANDC___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __CODEGEARC__ Chris@16: #define __CODEGEARC___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __CODEGEARC___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _MSC_VER Chris@16: #define _MSC_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _MSC_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _MSC_FULL_VER Chris@16: #define _MSC_FULL_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _MSC_FULL_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_MSVC Chris@16: #define BOOST_MSVC_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_MSVC_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_MSVC_FULL_VER Chris@16: #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __GNUC__ Chris@16: #define __GNUC___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __GNUC___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __GNUC_MINOR__ Chris@16: #define __GNUC_MINOR___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __GNUC_MINOR___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __GNUC_PATCHLEVEL__ Chris@16: #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __IBMCPP__ Chris@16: #define __IBMCPP___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __IBMCPP___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __SUNPRO_CC Chris@16: #define __SUNPRO_CC_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __SUNPRO_CC_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __DECCXX_VER Chris@16: #define __DECCXX_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __DECCXX_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __MWERKS__ Chris@16: #define __MWERKS___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __MWERKS___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __EDG__ Chris@16: #define __EDG___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __EDG___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __EDG_VERSION__ Chris@16: #define __EDG_VERSION___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __EDG_VERSION___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __HP_aCC Chris@16: #define __HP_aCC_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __HP_aCC_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __hpxstd98 Chris@16: #define __hpxstd98_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __hpxstd98_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _CRAYC Chris@16: #define _CRAYC_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _CRAYC_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __DMC__ Chris@16: #define __DMC___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __DMC___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef MPW_CPLUS Chris@16: #define MPW_CPLUS_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define MPW_CPLUS_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __COMO__ Chris@16: #define __COMO___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __COMO___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __COMO_VERSION__ Chris@16: #define __COMO_VERSION___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __COMO_VERSION___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __INTEL_COMPILER Chris@16: #define __INTEL_COMPILER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __INTEL_COMPILER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __ICL Chris@16: #define __ICL_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __ICL_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _COMPILER_VERSION Chris@16: #define _COMPILER_VERSION_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _COMPILER_VERSION_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: Chris@16: #ifndef _RWSTD_VER Chris@16: #define _RWSTD_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _RWSTD_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_RWSTD_VER Chris@16: #define BOOST_RWSTD_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_RWSTD_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __GLIBCPP__ Chris@16: #define __GLIBCPP___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __GLIBCPP___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC Chris@16: #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __SGI_STL_PORT Chris@16: #define __SGI_STL_PORT_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __SGI_STL_PORT_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _STLPORT_VERSION Chris@16: #define _STLPORT_VERSION_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _STLPORT_VERSION_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef __LIBCOMO_VERSION__ Chris@16: #define __LIBCOMO_VERSION___WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define __LIBCOMO_VERSION___WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef _CPPLIB_VER Chris@16: #define _CPPLIB_VER_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define _CPPLIB_VER_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: Chris@16: #ifndef BOOST_INTEL_CXX_VERSION Chris@16: #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_INTEL_WIN Chris@16: #define BOOST_INTEL_WIN_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_INTEL_WIN_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_DINKUMWARE_STDLIB Chris@16: #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: #ifndef BOOST_INTEL Chris@16: #define BOOST_INTEL_WORKAROUND_GUARD 1 Chris@16: #else Chris@16: #define BOOST_INTEL_WORKAROUND_GUARD 0 Chris@16: #endif Chris@16: // Always define to zero, if it's used it'll be defined my MPL: Chris@16: #define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0 Chris@16: Chris@16: # define BOOST_WORKAROUND(symbol, test) \ Chris@16: ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \ Chris@16: (symbol != 0) && (1 % (( (symbol test) ) + 1))) Chris@16: // ^ ^ ^ ^ Chris@16: // The extra level of parenthesis nesting above, along with the Chris@16: // BOOST_OPEN_PAREN indirection below, is required to satisfy the Chris@16: // broken preprocessor in MWCW 8.3 and earlier. Chris@16: // Chris@16: // The basic mechanism works as follows: Chris@16: // (symbol test) + 1 => if (symbol test) then 2 else 1 Chris@16: // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0 Chris@16: // Chris@16: // The complication with % is for cooperation with BOOST_TESTED_AT(). Chris@16: // When "test" is BOOST_TESTED_AT(x) and Chris@16: // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined, Chris@16: // Chris@16: // symbol test => if (symbol <= x) then 1 else -1 Chris@16: // (symbol test) + 1 => if (symbol <= x) then 2 else 0 Chris@16: // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero Chris@16: // Chris@16: Chris@16: # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS Chris@16: # define BOOST_OPEN_PAREN ( Chris@16: # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1 Chris@16: # else Chris@16: # define BOOST_TESTED_AT(value) != ((value)-(value)) Chris@16: # endif Chris@16: Chris@16: # else Chris@16: Chris@16: # define BOOST_WORKAROUND(symbol, test) 0 Chris@16: Chris@16: # endif Chris@16: Chris@16: #endif // WORKAROUND_DWA2002126_HPP