sl@0: // Copyright David Abrahams 2002. sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef WORKAROUND_DWA2002126_HPP sl@0: # define WORKAROUND_DWA2002126_HPP sl@0: sl@0: // Compiler/library version workaround macro sl@0: // sl@0: // Usage: sl@0: // sl@0: // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) sl@0: // // workaround for eVC4 and VC6 sl@0: // ... // workaround code here sl@0: // #endif sl@0: // sl@0: // When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the sl@0: // first argument must be undefined or expand to a numeric sl@0: // value. The above expands to: sl@0: // sl@0: // (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300 sl@0: // sl@0: // When used for workarounds that apply to the latest known version sl@0: // and all earlier versions of a compiler, the following convention sl@0: // should be observed: sl@0: // sl@0: // #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301)) sl@0: // sl@0: // The version number in this case corresponds to the last version in sl@0: // which the workaround was known to have been required. When sl@0: // BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro sl@0: // BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates sl@0: // the workaround for any version of the compiler. When sl@0: // BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or sl@0: // error will be issued if the compiler version exceeds the argument sl@0: // to BOOST_TESTED_AT(). This can be used to locate workarounds which sl@0: // may be obsoleted by newer versions. sl@0: sl@0: # ifndef BOOST_STRICT_CONFIG sl@0: sl@0: # define BOOST_WORKAROUND(symbol, test) \ sl@0: ((symbol != 0) && (1 % (( (symbol test) ) + 1))) sl@0: // ^ ^ ^ ^ sl@0: // The extra level of parenthesis nesting above, along with the sl@0: // BOOST_OPEN_PAREN indirection below, is required to satisfy the sl@0: // broken preprocessor in MWCW 8.3 and earlier. sl@0: // sl@0: // The basic mechanism works as follows: sl@0: // (symbol test) + 1 => if (symbol test) then 2 else 1 sl@0: // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0 sl@0: // sl@0: // The complication with % is for cooperation with BOOST_TESTED_AT(). sl@0: // When "test" is BOOST_TESTED_AT(x) and sl@0: // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined, sl@0: // sl@0: // symbol test => if (symbol <= x) then 1 else -1 sl@0: // (symbol test) + 1 => if (symbol <= x) then 2 else 0 sl@0: // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero sl@0: // sl@0: sl@0: # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS sl@0: # define BOOST_OPEN_PAREN ( sl@0: # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1 sl@0: # else sl@0: # define BOOST_TESTED_AT(value) != ((value)-(value)) sl@0: # endif sl@0: sl@0: # else sl@0: sl@0: # define BOOST_WORKAROUND(symbol, test) 0 sl@0: sl@0: # endif sl@0: sl@0: #endif // WORKAROUND_DWA2002126_HPP