|
113 | 113 | # define OSL_MSVS_BEFORE_2015 (_MSC_VER < 1900) |
114 | 114 | # define OSL_MSVS_AT_LEAST_2017 (_MSC_VER >= 1910) |
115 | 115 | # define OSL_MSVS_BEFORE_2017 (_MSC_VER < 1910) |
| 116 | +# define OSL_MSVS_AT_LEAST_2019 (_MSC_VER >= 1920) |
| 117 | +# define OSL_MSVS_BEFORE_2019 (_MSC_VER < 1920) |
| 118 | +# define OSL_MSVS_AT_LEAST_2022 (_MSC_VER >= 1930) |
| 119 | +# define OSL_MSVS_BEFORE_2022 (_MSC_VER < 1930) |
116 | 120 | # if OSL_MSVS_BEFORE_2017 |
117 | 121 | # error "This version of OSL is meant to work only with Visual Studio 2017 or later" |
118 | 122 | # endif |
|
124 | 128 | # define OSL_MSVS_BEFORE_2015 0 |
125 | 129 | # define OSL_MSVS_AT_LEAST_2017 0 |
126 | 130 | # define OSL_MSVS_BEFORE_2017 0 |
| 131 | +# define OSL_MSVS_AT_LEAST_2019 0 |
| 132 | +# define OSL_MSVS_BEFORE_2019 0 |
| 133 | +# define OSL_MSVS_AT_LEAST_2022 0 |
| 134 | +# define OSL_MSVS_BEFORE_2022 0 |
127 | 135 | #endif |
128 | 136 |
|
129 | 137 |
|
|
132 | 140 | // Detect which C++ standard we're using, and handy macros. |
133 | 141 | // See https://en.cppreference.com/w/cpp/compiler_support |
134 | 142 | // |
135 | | -// Note: oslversion.h defines OSL_BUILD_CPP to be 14, 17, etc., to reflect |
| 143 | +// Note: oslversion.h defines OSL_BUILD_CPP to be 17, 20, etc., to reflect |
136 | 144 | // the version that OSL itself was built with. In contrast, |
137 | 145 | // OSL_CPLUSPLUS_VERSION defined below will be set to the right number for |
138 | 146 | // the C++ standard being compiled RIGHT NOW by whomever is parsing these |
139 | 147 | // header files. These two things may be the same when compiling OSL, but |
140 | 148 | // they may not be the same if another package is compiling against OSL and |
141 | | -// using these headers (e.g., OSL may be C++14 but the client package may be |
| 149 | +// using these headers (e.g., OSL may be C++17 but the client package may be |
142 | 150 | // newer, or vice versa -- use these two symbols to differentiate these |
143 | 151 | // cases, when important). |
144 | 152 | #if (__cplusplus >= 202001L) |
145 | 153 | # define OSL_CPLUSPLUS_VERSION 20 |
146 | | -# define OSL_CONSTEXPR17 constexpr |
147 | 154 | # define OSL_CONSTEXPR20 constexpr |
148 | | -#elif (__cplusplus >= 201703L) |
| 155 | +#elif (__cplusplus >= 201703L) || (defined(_MSC_VER) && _MSC_VER >= 1914) |
149 | 156 | # define OSL_CPLUSPLUS_VERSION 17 |
150 | | -# define OSL_CONSTEXPR17 constexpr |
151 | | -# define OSL_CONSTEXPR20 /* not constexpr before C++20 */ |
152 | | -#elif (__cplusplus >= 201402L) || (defined(_MSC_VER) && _MSC_VER >= 1914) |
153 | | -# define OSL_CPLUSPLUS_VERSION 14 |
154 | | -# define OSL_CONSTEXPR17 /* not constexpr before C++17 */ |
155 | 157 | # define OSL_CONSTEXPR20 /* not constexpr before C++20 */ |
156 | 158 | #else |
157 | | -# error "This version of OSL requires C++14 or above" |
| 159 | +# error "This version of OSL requires C++17 or above" |
158 | 160 | #endif |
159 | 161 |
|
| 162 | +// DEPRECATED(1.14): use C++17 constexpr |
| 163 | +#define OSL_CONSTEXPR17 constexpr |
| 164 | + |
160 | 165 | // DEPRECATED(1.12): use C++14 constexpr |
161 | 166 | #define OSL_CONSTEXPR14 constexpr |
162 | 167 |
|
|
339 | 344 |
|
340 | 345 | // OSL_MAYBE_UNUSED is a function or variable attribute that assures the |
341 | 346 | // compiler that it's fine for the item to appear to be unused. |
342 | | -#if OSL_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(maybe_unused) |
343 | | -# define OSL_MAYBE_UNUSED [[maybe_unused]] |
344 | | -#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) || __has_attribute(unused) |
345 | | -# define OSL_MAYBE_UNUSED __attribute__((unused)) |
346 | | -#else |
347 | | -# define OSL_MAYBE_UNUSED |
348 | | -#endif |
| 347 | +// Consider this deprecated (as of OSL 1.14, C++17 minimum), you should favor |
| 348 | +// C++17's [[maybe_unused]] attribute. |
| 349 | +#define OSL_MAYBE_UNUSED [[maybe_unused]] |
349 | 350 |
|
350 | 351 |
|
351 | 352 | // Some compilers define a special intrinsic to use in conditionals that can |
|
393 | 394 |
|
394 | 395 |
|
395 | 396 | // OSL_DEPRECATED before a function declaration marks it as deprecated in |
396 | | -// a way that will generate compile warnings if it is called (but will |
397 | | -// preserve linkage compatibility). |
398 | | -#if OSL_CPLUSPLUS_VERSION >= 14 || __has_cpp_attribute(deprecated) |
399 | | -# define OSL_DEPRECATED(msg) [[deprecated(msg)]] |
400 | | -#elif defined(__GNUC__) || defined(__clang__) || __has_attribute(deprecated) |
401 | | -# define OSL_DEPRECATED(msg) __attribute__((deprecated(msg))) |
402 | | -#elif defined(_MSC_VER) |
403 | | -# define OSL_DEPRECATED(msg) __declspec(deprecated(msg)) |
404 | | -#else |
405 | | -# define OSL_DEPRECATED(msg) |
406 | | -#endif |
| 397 | +// a way that will generate compile warnings if it is called. This should |
| 398 | +// itself be considered deprecated (as of OSL 1.14) and code should use |
| 399 | +// [[deprecated(msg)]] instead. |
| 400 | +#define OSL_DEPRECATED(msg) [[deprecated(msg)]] |
| 401 | + |
407 | 402 |
|
408 | 403 | // OSL_FALLTHROUGH at the end of a `case` label's statements documents that |
409 | 404 | // the switch statement case is intentionally falling through to the code for |
410 | 405 | // the next case. |
411 | | -#if OSL_CPLUSPLUS_VERSION >= 17 || __has_cpp_attribute(fallthrough) |
412 | | -# define OSL_FALLTHROUGH [[fallthrough]] |
413 | | -#else |
414 | | -# define OSL_FALLTHROUGH |
415 | | -#endif |
| 406 | +// Consider this deprecated (as of OSL 1.14), you should favor C++17's |
| 407 | +// [[fallthrough]] attribute. |
| 408 | +#define OSL_FALLTHROUGH [[fallthrough]] |
416 | 409 |
|
417 | 410 |
|
418 | 411 | // OSL_NODISCARD following a function declaration documents that the |
|
0 commit comments