318
|
1 #ifndef TOML11_VERSION_HPP
|
|
2 #define TOML11_VERSION_HPP
|
|
3
|
|
4 // This file checks C++ version.
|
|
5
|
|
6 #ifndef __cplusplus
|
|
7 # error "__cplusplus is not defined"
|
|
8 #endif
|
|
9
|
|
10 // Since MSVC does not define `__cplusplus` correctly unless you pass
|
|
11 // `/Zc:__cplusplus` when compiling, the workaround macros are added.
|
|
12 // Those enables you to define version manually or to use MSVC specific
|
|
13 // version macro automatically.
|
|
14 //
|
|
15 // The value of `__cplusplus` macro is defined in the C++ standard spec, but
|
|
16 // MSVC ignores the value, maybe because of backward compatibility. Instead,
|
|
17 // MSVC defines _MSVC_LANG that has the same value as __cplusplus defined in
|
|
18 // the C++ standard. First we check the manual version definition, and then
|
|
19 // we check if _MSVC_LANG is defined. If neither, use normal `__cplusplus`.
|
|
20 //
|
|
21 // FYI: https://docs.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170
|
|
22 // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
|
|
23 //
|
|
24 #if defined(TOML11_ENFORCE_CXX11)
|
|
25 # define TOML11_CPLUSPLUS_STANDARD_VERSION 201103L
|
|
26 #elif defined(TOML11_ENFORCE_CXX14)
|
|
27 # define TOML11_CPLUSPLUS_STANDARD_VERSION 201402L
|
|
28 #elif defined(TOML11_ENFORCE_CXX17)
|
|
29 # define TOML11_CPLUSPLUS_STANDARD_VERSION 201703L
|
|
30 #elif defined(TOML11_ENFORCE_CXX20)
|
|
31 # define TOML11_CPLUSPLUS_STANDARD_VERSION 202002L
|
|
32 #elif defined(_MSVC_LANG) && defined(_MSC_VER) && 1910 <= _MSC_VER
|
|
33 # define TOML11_CPLUSPLUS_STANDARD_VERSION _MSVC_LANG
|
|
34 #else
|
|
35 # define TOML11_CPLUSPLUS_STANDARD_VERSION __cplusplus
|
|
36 #endif
|
|
37
|
|
38 #if TOML11_CPLUSPLUS_STANDARD_VERSION < 201103L && _MSC_VER < 1900
|
|
39 # error "toml11 requires C++11 or later."
|
|
40 #endif
|
|
41
|
|
42 #endif// TOML11_VERSION_HPP
|