c++11 - GNU 和 ICC 编译器之间的差异 : command line warning #10370: option '-std=c++11' is not valid for C compilations

标签 c++11 gcc intel

我在使用英特尔编译器编译一些 C++ 代码时遇到了困难,而 GCC 编译器可以毫无错误地完成这项工作。

考虑以下主要功能:

main.cpp

#include <iostream>
#include <stdlib.h>
#include <vector>
#include <stdio.h>
#include "my_func_data.h"
int main()
{   
    my_func_data dataFunction;
    dataFunction.vec.push_back(1);
    dataFunction.vec.push_back(2);
    dataFunction.vec.push_back(3);
    dataFunction.vec.push_back(4);

    for(int i=0;i<4;i++){
        printf("%f\n",dataFunction.vec[i]);
    }

 return 0;
 }

其中 my_func_data.h 是一个结构,必须位于单独的头文件中(为了演示问题)。

#ifndef my_func_data_H_
#define my_func_data_H_

#include <stdio.h>
#include <stdlib.h>
#include <vector>

typedef struct 
{   
    std::vector<double>vec;
} 
my_func_data;
#endif 

现在我加载两个编译器并尝试使用每个编译器来编译这两个函数。

第一次使用 gnu 编译器:

module load compiler/gnu-6.2.0
g++ -std=c++11 Main.cpp  my_func_data.h -o main
./main
1.000000
2.000000
3.000000
4.000000

接下来使用英特尔编译器

module load compiler/intel-15.0
icc -std=c++11 Main.cpp  my_func_data.h -o main
icc: command line warning #10370: option '-std=c++11' is not valid for C compilations
my_func_data.h(6): catastrophic error: cannot open source file "vector"
  #include <vector>
                   ^

什么会阻止 ICC 编译器编译代码? 此外,我是否应该将结构体 my_func_data 嵌入到它编译并执行的主函数中?

预先感谢您提供任何见解!

最佳答案

icc 是 C 编译器。 C++ 编译器是 icpc

这类似于 gccg++

关于c++11 - GNU 和 ICC 编译器之间的差异 : command line warning #10370: option '-std=c++11' is not valid for C compilations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46159729/

相关文章:

c++ - 有没有一种可移植的方法来知道 uintptr_t 是否在 stdint.h 中定义?

c++ - 提取文件重复信息

c++ - 在Jenkins "exec"中运行 "Execute Shell"命令

c++ - GCC 中的元组模板

python - pip 在 Mac OS X Mavericks (10.9) 上引发 stdio.h not found 错误

api - 什么是标签匹配接口(interface)?

c++ - 将嵌套的 std::arrays 视为具有链式 .data() 的单个平面数组

c - "make clean"导致 "make all"失败

x86 - 英特尔x86处理器的整数除法算法

linux - 当另一个进程共享相同的HT内核时,为什么一个进程的执行时间更短