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 BOOST_BORLANDC
54#define BOOST_BORLANDC_WORKAROUND_GUARD 1
55#else
56#define BOOST_BORLANDC_WORKAROUND_GUARD 0
57#endif
58#ifndef BOOST_CODEGEARC
59#define BOOST_CODEGEARC_WORKAROUND_GUARD 1
60#else
61#define BOOST_CODEGEARC_WORKAROUND_GUARD 0
62#endif
63#ifndef BOOST_EMBTC
64#define BOOST_EMBTC_WORKAROUND_GUARD 1
65#else
66#define BOOST_EMBTC_WORKAROUND_GUARD 0
67#endif
68#ifndef _MSC_VER
69#define _MSC_VER_WORKAROUND_GUARD 1
70#else
71#define _MSC_VER_WORKAROUND_GUARD 0
72#endif
73#ifndef _MSC_FULL_VER
74#define _MSC_FULL_VER_WORKAROUND_GUARD 1
75#else
76#define _MSC_FULL_VER_WORKAROUND_GUARD 0
77#endif
78#ifndef BOOST_MSVC
79#define BOOST_MSVC_WORKAROUND_GUARD 1
80#else
81#define BOOST_MSVC_WORKAROUND_GUARD 0
82#endif
83#ifndef BOOST_MSVC_FULL_VER
84#define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1
85#else
86#define BOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0
87#endif
88#ifndef __GNUC__
89#define __GNUC___WORKAROUND_GUARD 1
90#else
91#define __GNUC___WORKAROUND_GUARD 0
92#endif
93#ifndef __GNUC_MINOR__
94#define __GNUC_MINOR___WORKAROUND_GUARD 1
95#else
96#define __GNUC_MINOR___WORKAROUND_GUARD 0
97#endif
98#ifndef __GNUC_PATCHLEVEL__
99#define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 1
100#else
101#define __GNUC_PATCHLEVEL___WORKAROUND_GUARD 0
102#endif
103#ifndef BOOST_GCC
104#define BOOST_GCC_WORKAROUND_GUARD 1
105#define BOOST_GCC_VERSION_WORKAROUND_GUARD 1
106#else
107#define BOOST_GCC_WORKAROUND_GUARD 0
108#define BOOST_GCC_VERSION_WORKAROUND_GUARD 0
109#endif
110#ifndef BOOST_XLCPP_ZOS
111#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 1
112#else
113#define BOOST_XLCPP_ZOS_WORKAROUND_GUARD 0
114#endif
115#ifndef __IBMCPP__
116#define __IBMCPP___WORKAROUND_GUARD 1
117#else
118#define __IBMCPP___WORKAROUND_GUARD 0
119#endif
120#ifndef __SUNPRO_CC
121#define __SUNPRO_CC_WORKAROUND_GUARD 1
122#else
123#define __SUNPRO_CC_WORKAROUND_GUARD 0
124#endif
125#ifndef __DECCXX_VER
126#define __DECCXX_VER_WORKAROUND_GUARD 1
127#else
128#define __DECCXX_VER_WORKAROUND_GUARD 0
129#endif
130#ifndef __MWERKS__
131#define __MWERKS___WORKAROUND_GUARD 1
132#else
133#define __MWERKS___WORKAROUND_GUARD 0
134#endif
135#ifndef __EDG__
136#define __EDG___WORKAROUND_GUARD 1
137#else
138#define __EDG___WORKAROUND_GUARD 0
139#endif
140#ifndef __EDG_VERSION__
141#define __EDG_VERSION___WORKAROUND_GUARD 1
142#else
143#define __EDG_VERSION___WORKAROUND_GUARD 0
144#endif
145#ifndef __HP_aCC
146#define __HP_aCC_WORKAROUND_GUARD 1
147#else
148#define __HP_aCC_WORKAROUND_GUARD 0
149#endif
150#ifndef __hpxstd98
151#define __hpxstd98_WORKAROUND_GUARD 1
152#else
153#define __hpxstd98_WORKAROUND_GUARD 0
154#endif
155#ifndef _CRAYC
156#define _CRAYC_WORKAROUND_GUARD 1
157#else
158#define _CRAYC_WORKAROUND_GUARD 0
159#endif
160#ifndef __DMC__
161#define __DMC___WORKAROUND_GUARD 1
162#else
163#define __DMC___WORKAROUND_GUARD 0
164#endif
165#ifndef MPW_CPLUS
166#define MPW_CPLUS_WORKAROUND_GUARD 1
167#else
168#define MPW_CPLUS_WORKAROUND_GUARD 0
169#endif
170#ifndef __COMO__
171#define __COMO___WORKAROUND_GUARD 1
172#else
173#define __COMO___WORKAROUND_GUARD 0
174#endif
175#ifndef __COMO_VERSION__
176#define __COMO_VERSION___WORKAROUND_GUARD 1
177#else
178#define __COMO_VERSION___WORKAROUND_GUARD 0
179#endif
180#ifndef __INTEL_COMPILER
181#define __INTEL_COMPILER_WORKAROUND_GUARD 1
182#else
183#define __INTEL_COMPILER_WORKAROUND_GUARD 0
184#endif
185#ifndef __ICL
186#define __ICL_WORKAROUND_GUARD 1
187#else
188#define __ICL_WORKAROUND_GUARD 0
189#endif
190#ifndef _COMPILER_VERSION
191#define _COMPILER_VERSION_WORKAROUND_GUARD 1
192#else
193#define _COMPILER_VERSION_WORKAROUND_GUARD 0
194#endif
195#ifndef __clang_major__
196#define __clang_major___WORKAROUND_GUARD 1
197#else
198#define __clang_major___WORKAROUND_GUARD 0
199#endif
200
201#ifndef _RWSTD_VER
202#define _RWSTD_VER_WORKAROUND_GUARD 1
203#else
204#define _RWSTD_VER_WORKAROUND_GUARD 0
205#endif
206#ifndef BOOST_RWSTD_VER
207#define BOOST_RWSTD_VER_WORKAROUND_GUARD 1
208#else
209#define BOOST_RWSTD_VER_WORKAROUND_GUARD 0
210#endif
211#ifndef __GLIBCPP__
212#define __GLIBCPP___WORKAROUND_GUARD 1
213#else
214#define __GLIBCPP___WORKAROUND_GUARD 0
215#endif
216#ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
217#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1
218#else
219#define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0
220#endif
221#ifndef __SGI_STL_PORT
222#define __SGI_STL_PORT_WORKAROUND_GUARD 1
223#else
224#define __SGI_STL_PORT_WORKAROUND_GUARD 0
225#endif
226#ifndef _STLPORT_VERSION
227#define _STLPORT_VERSION_WORKAROUND_GUARD 1
228#else
229#define _STLPORT_VERSION_WORKAROUND_GUARD 0
230#endif
231#ifndef __LIBCOMO_VERSION__
232#define __LIBCOMO_VERSION___WORKAROUND_GUARD 1
233#else
234#define __LIBCOMO_VERSION___WORKAROUND_GUARD 0
235#endif
236#ifndef _CPPLIB_VER
237#define _CPPLIB_VER_WORKAROUND_GUARD 1
238#else
239#define _CPPLIB_VER_WORKAROUND_GUARD 0
240#endif
241
242#ifndef BOOST_INTEL_CXX_VERSION
243#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1
244#else
245#define BOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0
246#endif
247#ifndef BOOST_INTEL_WIN
248#define BOOST_INTEL_WIN_WORKAROUND_GUARD 1
249#else
250#define BOOST_INTEL_WIN_WORKAROUND_GUARD 0
251#endif
252#ifndef BOOST_DINKUMWARE_STDLIB
253#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1
254#else
255#define BOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0
256#endif
257#ifndef BOOST_INTEL
258#define BOOST_INTEL_WORKAROUND_GUARD 1
259#else
260#define BOOST_INTEL_WORKAROUND_GUARD 0
261#endif
262#ifndef BOOST_CLANG_VERSION
263#define BOOST_CLANG_VERSION_WORKAROUND_GUARD 1
264#else
265#define BOOST_CLANG_VERSION_WORKAROUND_GUARD 0
266#endif
267
268// Always define to zero, if it's used it'll be defined my MPL:
269#define BOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0
270
271#define BOOST_WORKAROUND(symbol, test) \
272 ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \
273 (symbol != 0) && (1 % (( (symbol test) ) + 1)))
274// ^ ^ ^ ^
275// The extra level of parenthesis nesting above, along with the
276// BOOST_OPEN_PAREN indirection below, is required to satisfy the
277// broken preprocessor in MWCW 8.3 and earlier.
278//
279// The basic mechanism works as follows:
280// (symbol test) + 1 => if (symbol test) then 2 else 1
281// 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0
282//
283// The complication with % is for cooperation with BOOST_TESTED_AT().
284// When "test" is BOOST_TESTED_AT(x) and
285// BOOST_DETECT_OUTDATED_WORKAROUNDS is #defined,
286//
287// symbol test => if (symbol <= x) then 1 else -1
288// (symbol test) + 1 => if (symbol <= x) then 2 else 0
289// 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero
290//
291
292#ifdef BOOST_DETECT_OUTDATED_WORKAROUNDS
293# define BOOST_OPEN_PAREN (
294# define BOOST_TESTED_AT(value) > value) ?(-1): BOOST_OPEN_PAREN 1
295#else
296# define BOOST_TESTED_AT(value) != ((value)-(value))
297#endif
298
299#else
300
301#define BOOST_WORKAROUND(symbol, test) 0
302
303#endif
304
305#endif // BOOST_CONFIG_WORKAROUND_HPP
306

source code of boost/libs/config/include/boost/config/workaround.hpp