本文介绍了如何打开C ++ 0x的Intel C ++编译器12.1.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Arch Linux 3.2.1上安装了最新版本的Intel C ++ Compiler v12.1.2。当我使用icpc编译我的C ++文件

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

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



弹出警告

 警告#2928:当使用带有c ++ 0x选项的GNU版本4.6时,__GXX_EXPERIMENTAL_CXX0X__宏被禁用

我的main.cpp包含许多C ++ 0x功能,如右值引用,自动等。但英特尔编译器没有工作在C ++ 0x模式。如何打开其C ++ 0x功能?

解决方案

  1. 安装libstdc ++ 4.5(或更早版本)

  2. 使用 icpc -gcc-name 问题是Intel编译器不支持GNU编译器从版本4.6开始的所有C ++ 0x功能。这会导致与GNU libstdc ++头不兼容,因为目前所有的C ++ 0x功能都受到一个唯一的宏 __ GXX_EXPERIMENTAL_CXX0X __ 的保护,不能单独启用或禁用。


    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?

    解决方案

    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.

    这篇关于如何打开C ++ 0x的Intel C ++编译器12.1.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:28