C++0x detection

C++0x detection

At this moment it's impossible to detect when C++0x support enabled during compilation.
I think predefined macro should do the trick.

publicaciones de 14 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Quoting - creatorcray
At this moment it's impossible to detect when C++0x support enabled during compilation.
I think predefined macro should do the trick.

You may use -std:c++0x compiler option to to get support for C++0x. It is best to leave the internal details to driver implentor.

Quoting - Om Sachan (Intel)

You may use -std:c++0x compiler option to to get support for C++0x. It is best to leave the internal details to driver implentor.

No, I need something like:

#ifndef __cplusplus0x
#error C++0x compiler required.
#endif

MSVC has predefined macro __cplusplus, which is defined for c++ programs only.
It would be nice to have __cplusplus0x macro, which is defined for c++0x programs only (when -std:c++0x specified).

Quoting - creatorcray
No, I need something like:

#ifndef __cplusplus0x
#error C++0x compiler required.
#endif

MSVC has predefined macro __cplusplus, which is defined for c++ programs only.
It would be nice to have __cplusplus0x macro, which is defined for c++0x programs only (when -std:c++0x specified).

you may try macro __GXX_EXPERIMENTAL_CPP0X__ on linux.

Quoting - Om Sachan (Intel)

Quoting - creatorcray
No, I need something like:

#ifndef __cplusplus0x
#error C++0x compiler required.
#endif

MSVC has predefined macro __cplusplus, which is defined for c++ programs only.
It would be nice to have __cplusplus0x macro, which is defined for c++0x programs only (when -std:c++0x specified).

you may try macro __GXX_EXPERIMENTAL_CPP0X__ on linux.

Thanks, but I need for windows.

Quoting - creatorcray
Thanks, but I need for windows.

You may use compiler option /QdM to get the defined macros:

icl /QdM /E hello.cpp > diag1.txt
icl /Qstd:c++0x /QdM /E hello.cpp > diag.txt

Find out the difference id diag1.txt and diag.txt and use the information appropriately. In my experiment I found macro _MSC_EXTENSIONS is missing when using /Qstd:c++0x.

Quoting - Om Sachan (Intel)

Quoting - creatorcray
Thanks, but I need for windows.

You may use compiler option /QdM to get the defined macros:

icl /QdM /E hello.cpp > diag1.txt
icl /Qstd:c++0x /QdM /E hello.cpp > diag.txt

Find out the difference id diag1.txt and diag.txt and use the information appropriately. In my experiment I found macro _MSC_EXTENSIONS is missing when using /Qstd:c++0x.

Wow! That's really cool!
This behaviour is not guaranteed, but it works at least.
Thanks!

Quoting - Om Sachan (Intel)

You may use compiler option /QdM to get the defined macros:

icl /QdM /E hello.cpp > diag1.txt
icl /Qstd:c++0x /QdM /E hello.cpp > diag.txt

Find out the difference id diag1.txt and diag.txt and use the information appropriately. In my experiment I found macro _MSC_EXTENSIONS is missing when using /Qstd:c++0x.

While this trick might work for the moment, still a better, more reliable solution is very desirable. Does someone know if a macro to recognize partial C++0x support is going to be provided in future versions of Intel Compiler?

Quoting - Alexey Kukanov (Intel)

While this trick might work for the moment, still a better, more reliable solution is very desirable. Does someone know if a macro to recognize partial C++0x support is going to be provided in future versions of Intel Compiler?

Weareunaware ofthe Intel's current plan. You may submit the feature request to Intel premier support at http://premier.intel.com.

Greetings, I have the very same problem since I need to detect _Pragma at preprocessor time.

Depending on what you wish to do, it's problematical, as you need to set icpc -std=c++11 and have a g++ on PATH which also accepts that option.  If you don't have both of these, you won't get anywhere with compilation with the option set. 

You might do something with scripts using g++ -v and icpc -V to check version numbers, or possibly with autoconf, to check the versions without setting -std, then redo with -std=c++11 set.

On Windows, you could check compiler versions likewise; ICL 13.0 and newer use /Qstd=c++11 to invoke the partial C++-11 of Intel C++; using VS2010 or 2012 the apparently lesser degrees of C++11 support by the Microsoft CL are present with ICL 12.0 and newer without /Qstd.

g++ had some c++11 features turned on without the option for which icpc required the option to be set.

see http://software.intel.com/en-us/articles/c0x-features-supported-by-intel...

It's difficult to assess the varying degrees of partial support you will find among those compilers. 

I'm not sure that without a message to C++11 architects / designers something could be done ( I wouldn't accuse vendors of C++ compilers ). However, simple workarounds at a compile time could be used and I follow up on that next week with as much as possible technical detsils.

 

You are supposed to use the value of the macro __cplusplus. G++ 4.7 and later set the value to 201103L. Microsoft has not yet changed the value (it's still set to199711L  since they are still pretty far away from being c++11 standard compliant. I think what would be really useful are separate macros which would tell the user which c++11 (or c++14) features are implemented (these are called "feature macros"). A proposal is currently being worked on by the C++ committee to do that.

Judy

In the case of emitting a #error and stopping compilation, can you not include a declaration with an appropriate name that requires the desired feature.

static auto _WeRequireCPP11 = [](){returm;};

Or something like that.

If you want the preprocessor to support this for different code generation, then you could define your own macro and include the "assert" above to assure the compiler actually supports the feature and/or compiler option selected.

Jim Dempsey

www.quickthreadprogramming.com

Inicie sesión para dejar un comentario.