本文主要是介绍已解决:#error This file requires compiler and library support for the ***.cpp,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
- 运行代码出现的错误
- 错误原因
- 解决办法
运行代码出现的错误
e:\Desktop\C++\第六章>cd “e:\Desktop\C++\第六章” && g++ array_test.cpp -o array_test && "e:\Desktop\C++\第六章"array_test
In file included from C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/array:35:0,
from array_test.cpp:3:
C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the
^
array_test.cpp: In function ‘int main()’:
array_test.cpp:11:5: error: ‘default_random_engine’ was not declared in this scope
default_random_engine engine(static_cast(time(0)));
^
array_test.cpp:12:5: error: ‘uniform_int_distribution’ was not declared in this scope
uniform_int_distribution randomInt(1, 6);
^
array_test.cpp:12:30: error: expected primary-expression before ‘unsigned’
uniform_int_distribution randomInt(1, 6);
^
错误原因
cpp文件中包含C++11特有的内容
array对象
(此处还没弄明白,为什么array对象也是用不了)
default_random_engine
uniform_int_distribution
所使用的编译器不支持 ISO C++ 2011 标准。
解决办法
需要在编译命令中添加 -std=c++11 或 -std=gnu++11 选项来启用对该标准的支持。
g++ ***.cpp -o *** -std=c++11
注意:***处填写自己的文件名
这篇关于已解决:#error This file requires compiler and library support for the ***.cpp的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!