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 BOOST_CONFIG_WORKAROUND_HPP
6#define BOOST_CONFIG_WORKAROUND_HPP
7
8// Compiler/library version workaround macro
9//
10// Usage:
11//
12// #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
13// // workaround for eVC4 and VC6
14// ... // workaround code here
15// #endif
16//
17// When BOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the
18// first argument must be undefined or expand to a numeric
19// value. The above expands to:
20//
21// (BOOST_MSVC) != 0 && (BOOST_MSVC) < 1300
22//
23// When used for workarounds that apply to the latest known version
24// and all earlier versions of a compiler, the following convention
25// should be observed:
26//
27// #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1301))
28//
29// The version number in this case corresponds to the last version in
30// which the workaround was known to have been required. When
31// BOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro
32// BOOST_TESTED_AT(x) expands to "!= 0", which effectively activates
33// the workaround for any version of the compiler. When
34// BOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or
35// error will be issued if the compiler version exceeds the argument
36// to BOOST_TESTED_AT(). This can be used to locate workarounds which
37// may be obsoleted by newer versions.
38
39#ifndef BOOST_STRICT_CONFIG
40
41#include <boost/config.hpp>
42
43#ifndef __BORLANDC__
44#define __BORLANDC___WORKAROUND_GUARD 1
45#else
46#define __BORLANDC___WORKAROUND_GUARD 0
47#endif
48#ifndef __CODEGEARC__
49#define __CODEGEARC___WORKAROUND_GUARD 1
50#else
51#define __CODEGEARC___WORKAROUND_GUARD 0
52#endif
53#ifndef _MSC_VER
54#define _MSC_VER_WORKAROUND_GUARD 1
55#else
56#define _MSC_VER_WORKAROUND_GUARD 0
57#endif
58#ifndef _MSC_FULL_VER
59#define _MSC_FULL_VER_WORKAROUND_GUARD 1
60#else
61#define _MSC_FULL_VER_WORKAROUND_GUARD 0
62#endif
63#ifndef BOOST_MSVC
64#define BOOST_MSVC_WORKAROUND_GUARD 1
65#else
66#define BOOST_MSVC_WORKAROUND_GUARD 0
67#endif
68#ifndef BOOST_MSVC_FULL_VER
69#define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1
70#else
71#define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0
72#endif
73#ifndef __GNUC__
74#define __GNUC___WORKAROUND_GUARD 1
75#else
76#define __GNUC___WORKAROUND_GUARD 0
77#endif
78#ifndef __GNUC_MINOR__
79#define __GNUC_MINOR___WORKAROUND_GUARD 1
80#else
81#define __GNUC_MINOR___WORKAROUND_GUARD 0
82#endif
83#ifndef __GNUC_PATCHLEVEL__
84#define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 1
85#else
86#define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 0
87#endif
88#ifndef BOOST_GCC
89#define BOOST_GCC_WORKAROUND_GUARD 1
90#else
91#define BOOST_GCC_WORKAROUND_GUARD 0
92#endif
93#ifndef BOOST_XLCPP_ZOS
94#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 1
95#else
96#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 0
97#endif
98#ifndef __IBMCPP__
99#define __IBMCPP___WORKAROUND_GUARD 1
100#else
101#define __IBMCPP___WORKAROUND_GUARD 0
102#endif
103#ifndef __SUNPRO_CC
104#define __SUNPRO_CC_WORKAROUND_GUARD 1
105#else
106#define __SUNPRO_CC_WORKAROUND_GUARD 0
107#endif
108#ifndef __DECCXX_VER
109#define __DECCXX_VER_WORKAROUND_GUARD 1
110#else
111#define __DECCXX_VER_WORKAROUND_GUARD 0
112#endif
113#ifndef __MWERKS__
114#define __MWERKS___WORKAROUND_GUARD 1
115#else
116#define __MWERKS___WORKAROUND_GUARD 0
117#endif
118#ifndef __EDG__
119#define __EDG___WORKAROUND_GUARD 1
120#else
121#define __EDG___WORKAROUND_GUARD 0
122#endif
123#ifndef __EDG_VERSION__
124#define __EDG_VERSION___WORKAROUND_GUARD 1
125#else
126#define __EDG_VERSION___WORKAROUND_GUARD 0
127#endif
128#ifndef __HP_aCC
129#define __HP_aCC_WORKAROUND_GUARD 1
130#else
131#define __HP_aCC_WORKAROUND_GUARD 0
132#endif
133#ifndef __hpxstd98
134#define __hpxstd98_WORKAROUND_GUARD 1
135#else
136#define __hpxstd98_WORKAROUND_GUARD 0
137#endif
138#ifndef _CRAYC
139#define _CRAYC_WORKAROUND_GUARD 1
140#else
141#define _CRAYC_WORKAROUND_GUARD 0
142#endif
143#ifndef __DMC__
144#define __DMC___WORKAROUND_GUARD 1
145#else
146#define __DMC___WORKAROUND_GUARD 0
147#endif
148#ifndef MPW_CPLUS
149#define MPW_CPLUS_WORKAROUND_GUARD 1
150#else
151#define MPW_CPLUS_WORKAROUND_GUARD 0
152#endif
153#ifndef __COMO__
154#define __COMO___WORKAROUND_GUARD 1
155#else
156#define __COMO___WORKAROUND_GUARD 0
157#endif
158#ifndef __COMO_VERSION__
159#define __COMO_VERSION___WORKAROUND_GUARD 1
160#else
161#define __COMO_VERSION___WORKAROUND_GUARD 0
162#endif
163#ifndef __INTEL_COMPILER
164#define __INTEL_COMPILER_WORKAROUND_GUARD 1
165#else
166#define __INTEL_COMPILER_WORKAROUND_GUARD 0
167#endif
168#ifndef __ICL
169#define __ICL_WORKAROUND_GUARD 1
170#else
171#define __ICL_WORKAROUND_GUARD 0
172#endif
173#ifndef _COMPILER_VERSION
174#define _COMPILER_VERSION_WORKAROUND_GUARD 1
175#else
176#define _COMPILER_VERSION_WORKAROUND_GUARD 0
177#endif
178
179#ifndef _RWSTD_VER
180#define _RWSTD_VER_WORKAROUND_GUARD 1
181#else
182#define _RWSTD_VER_WORKAROUND_GUARD 0
183#endif
184#ifndef BOOST_RWSTD_VER
185#define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
186#else
187#define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
188#endif
189#ifndef __GLIBCPP__
190#define __GLIBCPP___WORKAROUND_GUARD 1
191#else
192#define __GLIBCPP___WORKAROUND_GUARD 0
193#endif
194#ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
195#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
196#else
197#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
198#endif
199#ifndef __SGI_STL_PORT
200#define __SGI_STL_PORT_WORKAROUND_GUARD 1
201#else
202#define __SGI_STL_PORT_WORKAROUND_GUARD 0
203#endif
204#ifndef _STLPORT_VERSION
205#define _STLPORT_VERSION_WORKAROUND_GUARD 1
206#else
207#define _STLPORT_VERSION_WORKAROUND_GUARD 0
208#endif
209#ifndef __LIBCOMO_VERSION__
210#define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
211#else
212#define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
213#endif
214#ifndef _CPPLIB_VER
215#define _CPPLIB_VER_WORKAROUND_GUARD 1
216#else
217#define _CPPLIB_VER_WORKAROUND_GUARD 0
218#endif
219
220#ifndef BOOST_INTEL_CXX_VERSION
221#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
222#else
223#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
224#endif
225#ifndef BOOST_INTEL_WIN
226#define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
227#else
228#define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
229#endif
230#ifndef BOOST_DINKUMWARE_STDLIB
231#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
232#else
233#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
234#endif
235#ifndef BOOST_INTEL
236#define BOOST_INTEL_WORKAROUND_GUARD 1
237#else
238#define BOOST_INTEL_WORKAROUND_GUARD 0
239#endif
240// Always define to zero, if it's used it'll be defined my MPL:
241#define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
242
243#define BOOST_WORKAROUND(symbol, test) \
244 ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
245 (symbol != 0) && (1 % (( (symbol test) ) + 1)))
246// ^ ^ ^ ^
247// The extra level of parenthesis nesting above, along with the
248// BOOST_OPEN_PAREN indirection below, is required to satisfy the
249// broken preprocessor in MWCW 8.3 and earlier.
250//
251// The basic mechanism works as follows:
252// (symbol test) + 1 => if (symbol test) then 2 else 1
253// 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
254//
255// The complication with % is for cooperation with BOOST_TESTED_AT().
256// When "test" is BOOST_TESTED_AT(x) and
257// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
258//
259// symbol test => if (symbol <= x) then 1 else -1
260// (symbol test) + 1 => if (symbol <= x) then 2 else 0
261// 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
262//
263
264#ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
265# define BOOST_OPEN_PAREN (
266# define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
267#else
268# define BOOST_TESTED_AT(value) != ((value)-(value))
269#endif
270
271#else
272
273#define BOOST_WORKAROUND(symbol, test) 0
274
275#endif
276
277#endif // BOOST_CONFIG_WORKAROUND_HPP
278