我在读这篇。我在支持的代码块13.12 IDE上测试了该程序,C++11
但在编译时失败,并且编译器显示多个错误。看程序。在在线编译器上工作正常,请参阅此
// bad_array_new_length example
#include <iostream> // std::cout
#include <exception> // std::exception
#include <new> // std::bad_array_new_length
int main() {
try {
int* p = new int[-1];
} catch (std::bad_array_new_length& e) {
std::cerr << "bad_array_new_length caught: " << e.what() << '\n';
} catch (std::exception& e) { // older compilers may throw other exceptions:
std::cerr << "some other standard exception caught: " << e.what() << '\n';
}
}
编译器错误:
7 12 [Error] expected type-specifier
7 37 [Error] expected unqualified-id before '&' token
7 37 [Error] expected ')' before '&' token
7 37 [Error] expected '{' before '&' token
7 39 [Error] 'e' was not declared in this scope
7 40 [Error] expected ';' before ')' token
9 5 [Error] expected primary-expression before 'catch'
9 5 [Error] expected ';' before 'catch'
这是怎么了?它是编译器错误还是C++11
在代码块13.12 IDE中不完全受支持?
请帮我。
您的编译器不支持std::bad_array_new_length
。
Google的最高结果为code blocks 13.12
:
codeblocks-13.12mingw-setup.exe文件包含来自TDM-GCC(4.7.1版,32位)的GCC编译器和GDB调试器。
和GCC 4.7.1发布于2012年。根据此邮件列表帖子,自2013年以来,甚至主干GCC都仅受支持std::bad_array_new_length
。
通过将GCC参考手册一分为二,我们可以确定GCC 4.8.4没有它,而GCC 4.9.2有。链接到的“在线编译器”运行GCC 4.9.2。
长话短说,您将需要更新的GCC。
“ C ++ 11支持”是一个非常宽泛的术语,您会发现,直到最近,它基本上从来都不意味着完整的C ++ 11支持。例如,直到GCC 4.9才完全不支持C ++ 11正则表达式。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句