3

Possible Duplicate:
GNU C++ how to check when -std=c++0x is in effect?

What I want to do is:

 #if defined(CPLUSPLUS_OXFLAG)
  //do something
 #else
  //do something else
 #endif

Now how can I capture -std=c++0x argument passed to the compiler(g++) to define my CPLUSPLUS_OXFLAG flag?

Community
  • 1
  • 1
A. K.
  • 34,395
  • 15
  • 52
  • 89
  • 1
    You could try something like `#if __cplusplus >= 201103L #define CPLUSPLUS_OXFLAG #endif`. –  Jul 22 '11 at 20:28
  • In standard C++0x, ["the macro __cplusplus will be set to a value that differs from (is greater than) the current 199711L"](http://www2.research.att.com/~bs/C++0xFAQ.html#0x). I'm not sure if the experimental C++0x GCC implementation will do that. – In silico Jul 22 '11 at 20:33

3 Answers3

2

The GCC documentation states that the preprocessor symbol __GXX_EXPERIMENTAL_CXX0X__ is defined when compiling with -std=c++0x.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
2

For GCC have a look at this:

__GXX_EXPERIMENTAL_CXX0X__

This macro is defined when compiling a C++ source file with the option -std=c++0x or -std=gnu++0x. It indicates that some features likely to be included in C++0x are available. Note that these features are experimental, and may change or be removed in future versions of GCC.

Find the reference here.

Alok Save
  • 202,538
  • 53
  • 430
  • 533
1

GCC defines __GXX_EXPERIMENTAL_CXX0X__ when std=c++0x is enabled.

Peter Alexander
  • 53,344
  • 14
  • 119
  • 168