workaround.hpp

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

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5