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#define BOOST_GCC_VERSION_WORKAROUND_GUARD 1
91#else
92#define BOOST_GCC_WORKAROUND_GUARD 0
93#define BOOST_GCC_VERSION_WORKAROUND_GUARD 0
94#endif
95#ifndef BOOST_XLCPP_ZOS
96#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 1
97#else
98#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 0
99#endif
100#ifndef __IBMCPP__
101#define __IBMCPP___WORKAROUND_GUARD 1
102#else
103#define __IBMCPP___WORKAROUND_GUARD 0
104#endif
105#ifndef __SUNPRO_CC
106#define __SUNPRO_CC_WORKAROUND_GUARD 1
107#else
108#define __SUNPRO_CC_WORKAROUND_GUARD 0
109#endif
110#ifndef __DECCXX_VER
111#define __DECCXX_VER_WORKAROUND_GUARD 1
112#else
113#define __DECCXX_VER_WORKAROUND_GUARD 0
114#endif
115#ifndef __MWERKS__
116#define __MWERKS___WORKAROUND_GUARD 1
117#else
118#define __MWERKS___WORKAROUND_GUARD 0
119#endif
120#ifndef __EDG__
121#define __EDG___WORKAROUND_GUARD 1
122#else
123#define __EDG___WORKAROUND_GUARD 0
124#endif
125#ifndef __EDG_VERSION__
126#define __EDG_VERSION___WORKAROUND_GUARD 1
127#else
128#define __EDG_VERSION___WORKAROUND_GUARD 0
129#endif
130#ifndef __HP_aCC
131#define __HP_aCC_WORKAROUND_GUARD 1
132#else
133#define __HP_aCC_WORKAROUND_GUARD 0
134#endif
135#ifndef __hpxstd98
136#define __hpxstd98_WORKAROUND_GUARD 1
137#else
138#define __hpxstd98_WORKAROUND_GUARD 0
139#endif
140#ifndef _CRAYC
141#define _CRAYC_WORKAROUND_GUARD 1
142#else
143#define _CRAYC_WORKAROUND_GUARD 0
144#endif
145#ifndef __DMC__
146#define __DMC___WORKAROUND_GUARD 1
147#else
148#define __DMC___WORKAROUND_GUARD 0
149#endif
150#ifndef MPW_CPLUS
151#define MPW_CPLUS_WORKAROUND_GUARD 1
152#else
153#define MPW_CPLUS_WORKAROUND_GUARD 0
154#endif
155#ifndef __COMO__
156#define __COMO___WORKAROUND_GUARD 1
157#else
158#define __COMO___WORKAROUND_GUARD 0
159#endif
160#ifndef __COMO_VERSION__
161#define __COMO_VERSION___WORKAROUND_GUARD 1
162#else
163#define __COMO_VERSION___WORKAROUND_GUARD 0
164#endif
165#ifndef __INTEL_COMPILER
166#define __INTEL_COMPILER_WORKAROUND_GUARD 1
167#else
168#define __INTEL_COMPILER_WORKAROUND_GUARD 0
169#endif
170#ifndef __ICL
171#define __ICL_WORKAROUND_GUARD 1
172#else
173#define __ICL_WORKAROUND_GUARD 0
174#endif
175#ifndef _COMPILER_VERSION
176#define _COMPILER_VERSION_WORKAROUND_GUARD 1
177#else
178#define _COMPILER_VERSION_WORKAROUND_GUARD 0
179#endif
180
181#ifndef _RWSTD_VER
182#define _RWSTD_VER_WORKAROUND_GUARD 1
183#else
184#define _RWSTD_VER_WORKAROUND_GUARD 0
185#endif
186#ifndef BOOST_RWSTD_VER
187#define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
188#else
189#define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
190#endif
191#ifndef __GLIBCPP__
192#define __GLIBCPP___WORKAROUND_GUARD 1
193#else
194#define __GLIBCPP___WORKAROUND_GUARD 0
195#endif
196#ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
197#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
198#else
199#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
200#endif
201#ifndef __SGI_STL_PORT
202#define __SGI_STL_PORT_WORKAROUND_GUARD 1
203#else
204#define __SGI_STL_PORT_WORKAROUND_GUARD 0
205#endif
206#ifndef _STLPORT_VERSION
207#define _STLPORT_VERSION_WORKAROUND_GUARD 1
208#else
209#define _STLPORT_VERSION_WORKAROUND_GUARD 0
210#endif
211#ifndef __LIBCOMO_VERSION__
212#define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
213#else
214#define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
215#endif
216#ifndef _CPPLIB_VER
217#define _CPPLIB_VER_WORKAROUND_GUARD 1
218#else
219#define _CPPLIB_VER_WORKAROUND_GUARD 0
220#endif
221
222#ifndef BOOST_INTEL_CXX_VERSION
223#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
224#else
225#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
226#endif
227#ifndef BOOST_INTEL_WIN
228#define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
229#else
230#define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
231#endif
232#ifndef BOOST_DINKUMWARE_STDLIB
233#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
234#else
235#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
236#endif
237#ifndef BOOST_INTEL
238#define BOOST_INTEL_WORKAROUND_GUARD 1
239#else
240#define BOOST_INTEL_WORKAROUND_GUARD 0
241#endif
242// Always define to zero, if it's used it'll be defined my MPL:
243#define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
244
245#define BOOST_WORKAROUND(symbol, test) \
246 ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
247 (symbol != 0) && (1 % (( (symbol test) ) + 1)))
248// ^ ^ ^ ^
249// The extra level of parenthesis nesting above, along with the
250// BOOST_OPEN_PAREN indirection below, is required to satisfy the
251// broken preprocessor in MWCW 8.3 and earlier.
252//
253// The basic mechanism works as follows:
254// (symbol test) + 1 => if (symbol test) then 2 else 1
255// 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
256//
257// The complication with % is for cooperation with BOOST_TESTED_AT().
258// When "test" is BOOST_TESTED_AT(x) and
259// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
260//
261// symbol test => if (symbol <= x) then 1 else -1
262// (symbol test) + 1 => if (symbol <= x) then 2 else 0
263// 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
264//
265
266#ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
267# define BOOST_OPEN_PAREN (
268# define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
269#else
270# define BOOST_TESTED_AT(value) != ((value)-(value))
271#endif
272
273#else
274
275#define BOOST_WORKAROUND(symbol, test) 0
276
277#endif
278
279#endif // BOOST_CONFIG_WORKAROUND_HPP
280