开发者

What is #defined if a compiler is Cpp0x compliant?

Is there any official, or inofficial, #defines for when a compiler i开发者_JAVA技巧s Cpp0x compliant? Even better, for specific Cpp0x functionality (~#cpp0xlambda, #cpp0xrvalue etc)?

(Haven't found anything about this on the net)


For C++03 according to 16.8/1 (Predefined macro names):

The name __cplusplus is defined to the value 199711L when compiling a C++ translation unit.

For C++0x draft n2857 according to 16.8/1 (Predefined macro names):

The name __cplusplus is defined to the value [tbd] when compiling a C++ translation unit.


Bjarne's C++0x FAQ says:

__cplusplus

In C++0x the macro __cplusplus will be set to a value that differs from (is greater than) the current 199711L.


The official spec includes a value for the __cplusplus preprocessor macro, but as others have pointed out, this suggests that everything in the spec is implemented. More to the point, no current compiler (that I know of) sets the appropriate value. Specs are well and good, but completely unimplemented bits of any spec should be considered tentative; the intersection of the spec and wide support is the real "standard".

A related question is "how can I tell if at least some C++0x support is enabled?", e.g. with the -std=c++0x compiler switch. The answer to that question is compiler-specific and subject to change, but both GCC 4.6 and Clang 2.1 set the preprocessor macro __GXX_EXPERIMENTAL_CXX0X__ (and give it value 1) when their partial C++0x support is enabled.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜