00001 // Copyright David Abrahams 2002. 00002 // Distributed under the Boost Software License, Version 1.0. (See 00003 // accompanying file LICENSE_1_0.txt or copy at 00004 // http://www.boost.org/LICENSE_1_0.txt) 00005 #ifndef WORKAROUND_DWA2002126_HPP 00006 # define WORKAROUND_DWA2002126_HPP 00007 00008 // Compiler/library version workaround macro 00009 // 00010 // Usage: 00011 // 00012 // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) 00013 // // workaround for eVC4 and VC6 00014 // ... // workaround code here 00015 // #endif 00016 // 00017 // When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the 00018 // first argument must be undefined or expand to a numeric 00019 // value. The above expands to: 00020 // 00021 // (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300 00022 // 00023 // When used for workarounds that apply to the latest known version 00024 // and all earlier versions of a compiler, the following convention 00025 // should be observed: 00026 // 00027 // #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301)) 00028 // 00029 // The version number in this case corresponds to the last version in 00030 // which the workaround was known to have been required. When 00031 // BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro 00032 // BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates 00033 // the workaround for any version of the compiler. When 00034 // BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or 00035 // error will be issued if the compiler version exceeds the argument 00036 // to BOOST_TESTED_AT(). This can be used to locate workarounds which 00037 // may be obsoleted by newer versions. 00038 00039 # ifndef BOOST_STRICT_CONFIG 00040 00041 # define BOOST_WORKAROUND(symbol, test) \ 00042 ((symbol != 0) && (1 % (( (symbol test) ) + 1))) 00043 // ^ ^ ^ ^ 00044 // The extra level of parenthesis nesting above, along with the 00045 // BOOST_OPEN_PAREN indirection below, is required to satisfy the 00046 // broken preprocessor in MWCW 8.3 and earlier. 00047 // 00048 // The basic mechanism works as follows: 00049 // (symbol test) + 1 => if (symbol test) then 2 else 1 00050 // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0 00051 // 00052 // The complication with % is for cooperation with BOOST_TESTED_AT(). 00053 // When "test" is BOOST_TESTED_AT(x) and 00054 // BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined, 00055 // 00056 // symbol test => if (symbol <= x) then 1 else -1 00057 // (symbol test) + 1 => if (symbol <= x) then 2 else 0 00058 // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero 00059 // 00060 00061 # ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS 00062 # define BOOST_OPEN_PAREN ( 00063 # define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1 00064 # else 00065 # define BOOST_TESTED_AT(value) != ((value)-(value)) 00066 # endif 00067 00068 # else 00069 00070 # define BOOST_WORKAROUND(symbol, test) 0 00071 00072 # endif 00073 00074 #endif // WORKAROUND_DWA2002126_HPP