source: NonGTP/Boost/boost/detail/workaround.hpp @ 857

Revision 857, 2.7 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[857]1// Copyright David Abrahams 2002.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef WORKAROUND_DWA2002126_HPP
6# define WORKAROUND_DWA2002126_HPP
7
8// Compiler/library version workaround macro
9//
10// Usage:
11//
12//     #if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
13//        ... // workaround code here
14//     #endif
15//
16// When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
17// first argument must be undefined or expand to a numeric
18// value. The above expands to:
19//
20//     (BOOST_MSVC) != 0 && (BOOST_MSVC) <= 1200
21//
22// When used for workarounds that apply to the latest known version
23// and all earlier versions of a compiler, the following convention
24// should be observed:
25//
26//     #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
27//
28// The version number in this case corresponds to the last version in
29// which the workaround was known to have been required. When
30// BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
31// BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
32// the workaround for any version of the compiler. When
33// BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
34// error will be issued if the compiler version exceeds the argument
35// to BOOST_TESTED_AT().  This can be used to locate workarounds which
36// may be obsoleted by newer versions.
37
38# ifndef BOOST_STRICT_CONFIG
39
40#  define BOOST_WORKAROUND(symbol, test)                \
41        ((symbol != 0) && (1 % (( (symbol test) ) + 1)))
42//                              ^ ^           ^ ^
43// The extra level of parenthesis nesting above, along with the
44// BOOST_OPEN_PAREN indirection below, is required to satisfy the
45// broken preprocessor in MWCW 8.3 and earlier.
46//
47// The basic mechanism works as follows:
48//      (symbol test) + 1        =>   if (symbol test) then 2 else 1
49//      1 % ((symbol test) + 1)  =>   if (symbol test) then 1 else 0
50//
51// The complication with % is for cooperation with BOOST_TESTED_AT().
52// When "test" is BOOST_TESTED_AT(x) and
53// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
54//
55//      symbol test              =>   if (symbol <= x) then 1 else -1
56//      (symbol test) + 1        =>   if (symbol <= x) then 2 else 0
57//      1 % ((symbol test) + 1)  =>   if (symbol <= x) then 1 else divide-by-zero
58//
59
60#  ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
61#   define BOOST_OPEN_PAREN (
62#   define BOOST_TESTED_AT(value)  > value) ?(-1): BOOST_OPEN_PAREN 1
63#  else
64#   define BOOST_TESTED_AT(value) != ((value)-(value))
65#  endif
66
67# else
68
69#  define BOOST_WORKAROUND(symbol, test) 0
70
71# endif
72
73#endif // WORKAROUND_DWA2002126_HPP
Note: See TracBrowser for help on using the repository browser.