c++c++11icc

How to turn on C++0x of Intel C++ Compiler 12.1.2


I installed the latest version of Intel C++ Compiler v12.1.2 on Arch Linux 3.2.1. When I used icpc to compile my C++ file

icpc -O3 -DNDEBUG -std=gnu++0x -o obj/main.o src/main.cpp -c

or

icpc -O3 -DNDEBUG -std=c++0x -o obj/main.o src/main.cpp -c

A warning popped out

Warning #2928: the __GXX_EXPERIMENTAL_CXX0X__ macro is disabled when using GNU version 4.6 with the c++0x option

My main.cpp contains many C++0x features such as rvalue references, auto, etc. But the Intel compiler did not work in C++0x mode. How to turn on its C++0x features?


Solution

  • I had to fight my way through this, but a quick solution seems to be:

    1. Install libstdc++4.5 (or earlier)
    2. compile with icpc -gcc-name=gcc-4.5 -std=c++0x

    The problem is that Intel compilers do not support all the C++0x features that GNU compilers do starting from version 4.6. This causes incompatibilities with GNU libstdc++ headers since at present all the C++0x features are protected by a unique macro __GXX_EXPERIMENTAL_CXX0X__ and cannot be enabled or disabled singularly.