Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 12 | // #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 13 | // // workaround for eVC4 and VC6 |
| 14 | // ... // workaround code here |
| 15 | // #endif |
| 16 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 17 | // When NDNBOOST_STRICT_CONFIG is defined, expands to 0. Otherwise, the |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 18 | // first argument must be undefined or expand to a numeric |
| 19 | // value. The above expands to: |
| 20 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 21 | // (NDNBOOST_MSVC) != 0 && (NDNBOOST_MSVC) < 1300 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 27 | // #if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, NDNBOOST_TESTED_AT(1301)) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 31 | // NDNBOOST_DETECT_OUTDATED_WORKAROUNDS is not the defined, the macro |
| 32 | // NDNBOOST_TESTED_AT(x) expands to "!= 0", which effectively activates |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 33 | // the workaround for any version of the compiler. When |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 34 | // NDNBOOST_DETECT_OUTDATED_WORKAROUNDS is defined, a compiler warning or |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 35 | // error will be issued if the compiler version exceeds the argument |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 36 | // to NDNBOOST_TESTED_AT(). This can be used to locate workarounds which |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 37 | // may be obsoleted by newer versions. |
| 38 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 39 | # ifndef NDNBOOST_STRICT_CONFIG |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 40 | |
Jeff Thompson | 2277ce5 | 2013-08-01 17:34:11 -0700 | [diff] [blame] | 41 | #include <ndnboost/config.hpp> |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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 |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 63 | #ifndef NDNBOOST_MSVC |
| 64 | #define NDNBOOST_MSVC_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 65 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 66 | #define NDNBOOST_MSVC_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 67 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 68 | #ifndef NDNBOOST_MSVC_FULL_VER |
| 69 | #define NDNBOOST_MSVC_FULL_VER_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 70 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 71 | #define NDNBOOST_MSVC_FULL_VER_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 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 __IBMCPP__ |
| 89 | #define __IBMCPP___WORKAROUND_GUARD 1 |
| 90 | #else |
| 91 | #define __IBMCPP___WORKAROUND_GUARD 0 |
| 92 | #endif |
| 93 | #ifndef __SUNPRO_CC |
| 94 | #define __SUNPRO_CC_WORKAROUND_GUARD 1 |
| 95 | #else |
| 96 | #define __SUNPRO_CC_WORKAROUND_GUARD 0 |
| 97 | #endif |
| 98 | #ifndef __DECCXX_VER |
| 99 | #define __DECCXX_VER_WORKAROUND_GUARD 1 |
| 100 | #else |
| 101 | #define __DECCXX_VER_WORKAROUND_GUARD 0 |
| 102 | #endif |
| 103 | #ifndef __MWERKS__ |
| 104 | #define __MWERKS___WORKAROUND_GUARD 1 |
| 105 | #else |
| 106 | #define __MWERKS___WORKAROUND_GUARD 0 |
| 107 | #endif |
| 108 | #ifndef __EDG__ |
| 109 | #define __EDG___WORKAROUND_GUARD 1 |
| 110 | #else |
| 111 | #define __EDG___WORKAROUND_GUARD 0 |
| 112 | #endif |
| 113 | #ifndef __EDG_VERSION__ |
| 114 | #define __EDG_VERSION___WORKAROUND_GUARD 1 |
| 115 | #else |
| 116 | #define __EDG_VERSION___WORKAROUND_GUARD 0 |
| 117 | #endif |
| 118 | #ifndef __HP_aCC |
| 119 | #define __HP_aCC_WORKAROUND_GUARD 1 |
| 120 | #else |
| 121 | #define __HP_aCC_WORKAROUND_GUARD 0 |
| 122 | #endif |
| 123 | #ifndef __hpxstd98 |
| 124 | #define __hpxstd98_WORKAROUND_GUARD 1 |
| 125 | #else |
| 126 | #define __hpxstd98_WORKAROUND_GUARD 0 |
| 127 | #endif |
| 128 | #ifndef _CRAYC |
| 129 | #define _CRAYC_WORKAROUND_GUARD 1 |
| 130 | #else |
| 131 | #define _CRAYC_WORKAROUND_GUARD 0 |
| 132 | #endif |
| 133 | #ifndef __DMC__ |
| 134 | #define __DMC___WORKAROUND_GUARD 1 |
| 135 | #else |
| 136 | #define __DMC___WORKAROUND_GUARD 0 |
| 137 | #endif |
| 138 | #ifndef MPW_CPLUS |
| 139 | #define MPW_CPLUS_WORKAROUND_GUARD 1 |
| 140 | #else |
| 141 | #define MPW_CPLUS_WORKAROUND_GUARD 0 |
| 142 | #endif |
| 143 | #ifndef __COMO__ |
| 144 | #define __COMO___WORKAROUND_GUARD 1 |
| 145 | #else |
| 146 | #define __COMO___WORKAROUND_GUARD 0 |
| 147 | #endif |
| 148 | #ifndef __COMO_VERSION__ |
| 149 | #define __COMO_VERSION___WORKAROUND_GUARD 1 |
| 150 | #else |
| 151 | #define __COMO_VERSION___WORKAROUND_GUARD 0 |
| 152 | #endif |
| 153 | #ifndef __INTEL_COMPILER |
| 154 | #define __INTEL_COMPILER_WORKAROUND_GUARD 1 |
| 155 | #else |
| 156 | #define __INTEL_COMPILER_WORKAROUND_GUARD 0 |
| 157 | #endif |
| 158 | #ifndef __ICL |
| 159 | #define __ICL_WORKAROUND_GUARD 1 |
| 160 | #else |
| 161 | #define __ICL_WORKAROUND_GUARD 0 |
| 162 | #endif |
| 163 | #ifndef _COMPILER_VERSION |
| 164 | #define _COMPILER_VERSION_WORKAROUND_GUARD 1 |
| 165 | #else |
| 166 | #define _COMPILER_VERSION_WORKAROUND_GUARD 0 |
| 167 | #endif |
| 168 | |
| 169 | #ifndef _RWSTD_VER |
| 170 | #define _RWSTD_VER_WORKAROUND_GUARD 1 |
| 171 | #else |
| 172 | #define _RWSTD_VER_WORKAROUND_GUARD 0 |
| 173 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 174 | #ifndef NDNBOOST_RWSTD_VER |
| 175 | #define NDNBOOST_RWSTD_VER_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 176 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 177 | #define NDNBOOST_RWSTD_VER_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 178 | #endif |
| 179 | #ifndef __GLIBCPP__ |
| 180 | #define __GLIBCPP___WORKAROUND_GUARD 1 |
| 181 | #else |
| 182 | #define __GLIBCPP___WORKAROUND_GUARD 0 |
| 183 | #endif |
| 184 | #ifndef _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC |
| 185 | #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 1 |
| 186 | #else |
| 187 | #define _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC_WORKAROUND_GUARD 0 |
| 188 | #endif |
| 189 | #ifndef __SGI_STL_PORT |
| 190 | #define __SGI_STL_PORT_WORKAROUND_GUARD 1 |
| 191 | #else |
| 192 | #define __SGI_STL_PORT_WORKAROUND_GUARD 0 |
| 193 | #endif |
| 194 | #ifndef _STLPORT_VERSION |
| 195 | #define _STLPORT_VERSION_WORKAROUND_GUARD 1 |
| 196 | #else |
| 197 | #define _STLPORT_VERSION_WORKAROUND_GUARD 0 |
| 198 | #endif |
| 199 | #ifndef __LIBCOMO_VERSION__ |
| 200 | #define __LIBCOMO_VERSION___WORKAROUND_GUARD 1 |
| 201 | #else |
| 202 | #define __LIBCOMO_VERSION___WORKAROUND_GUARD 0 |
| 203 | #endif |
| 204 | #ifndef _CPPLIB_VER |
| 205 | #define _CPPLIB_VER_WORKAROUND_GUARD 1 |
| 206 | #else |
| 207 | #define _CPPLIB_VER_WORKAROUND_GUARD 0 |
| 208 | #endif |
| 209 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 210 | #ifndef NDNBOOST_INTEL_CXX_VERSION |
| 211 | #define NDNBOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 212 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 213 | #define NDNBOOST_INTEL_CXX_VERSION_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 214 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 215 | #ifndef NDNBOOST_INTEL_WIN |
| 216 | #define NDNBOOST_INTEL_WIN_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 217 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 218 | #define NDNBOOST_INTEL_WIN_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 219 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 220 | #ifndef NDNBOOST_DINKUMWARE_STDLIB |
| 221 | #define NDNBOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 222 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 223 | #define NDNBOOST_DINKUMWARE_STDLIB_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 224 | #endif |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 225 | #ifndef NDNBOOST_INTEL |
| 226 | #define NDNBOOST_INTEL_WORKAROUND_GUARD 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 227 | #else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 228 | #define NDNBOOST_INTEL_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 229 | #endif |
| 230 | // Always define to zero, if it's used it'll be defined my MPL: |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 231 | #define NDNBOOST_MPL_CFG_GCC_WORKAROUND_GUARD 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 232 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 233 | # define NDNBOOST_WORKAROUND(symbol, test) \ |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 234 | ((symbol ## _WORKAROUND_GUARD + 0 == 0) && \ |
| 235 | (symbol != 0) && (1 % (( (symbol test) ) + 1))) |
| 236 | // ^ ^ ^ ^ |
| 237 | // The extra level of parenthesis nesting above, along with the |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 238 | // NDNBOOST_OPEN_PAREN indirection below, is required to satisfy the |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 239 | // broken preprocessor in MWCW 8.3 and earlier. |
| 240 | // |
| 241 | // The basic mechanism works as follows: |
| 242 | // (symbol test) + 1 => if (symbol test) then 2 else 1 |
| 243 | // 1 % ((symbol test) + 1) => if (symbol test) then 1 else 0 |
| 244 | // |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 245 | // The complication with % is for cooperation with NDNBOOST_TESTED_AT(). |
| 246 | // When "test" is NDNBOOST_TESTED_AT(x) and |
| 247 | // NDNBOOST_DETECT_OUTDATED_WORKAROUNDS is #defined, |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 248 | // |
| 249 | // symbol test => if (symbol <= x) then 1 else -1 |
| 250 | // (symbol test) + 1 => if (symbol <= x) then 2 else 0 |
| 251 | // 1 % ((symbol test) + 1) => if (symbol <= x) then 1 else divide-by-zero |
| 252 | // |
| 253 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 254 | # ifdef NDNBOOST_DETECT_OUTDATED_WORKAROUNDS |
| 255 | # define NDNBOOST_OPEN_PAREN ( |
| 256 | # define NDNBOOST_TESTED_AT(value) > value) ?(-1): NDNBOOST_OPEN_PAREN 1 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 257 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 258 | # define NDNBOOST_TESTED_AT(value) != ((value)-(value)) |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 259 | # endif |
| 260 | |
| 261 | # else |
| 262 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 263 | # define NDNBOOST_WORKAROUND(symbol, test) 0 |
Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame] | 264 | |
| 265 | # endif |
| 266 | |
| 267 | #endif // WORKAROUND_DWA2002126_HPP |