GCCG with C++11

Jonathan Wakely jwakely.gcc@gmail.com
Thu May 28 16:31:00 GMT 2015


On 28 May 2015 at 16:51, Martin Sebor wrote:
> The standard specifies that implementations conforming to C++
> 11 must define the __cplusplus macro to 201103L, and recommends
> that non-conforming compilers (presumably those that aim to be
> C++11 conforming but whose support is incomplete) should use
> a value with at most five decimal digits.
>
> C++ 98 defines __cplusplus to 199711L, and C++ 14 to 201402L.
>
> With that, the following should cover past and future cases:
>
>   #if __cplusplus == 199711L
>     // C++ 98 conforming implementation
>   #elif __cplusplus == 201103L
>     // C++ 11 conforming implementation
>   #elif __cplusplus == 201402L
>     // C++ 14 conforming implementation
>   #elif __cplusplus > 201402L
>     // future C++ implementation
>   #elif 0 < __cplusplus && __cplusplus < 100000L
>     // non-conforming C++ implementation
>   #else
>     // not C++ or a non-conforming C++ implementation
>   #endif

Until GCC 4.7.0 __cplusplus was always defined to 1, even though C++11
support in 4.6.4 was OK, and C++98 support was mostly complete.



More information about the Gcc-help mailing list