Des*_*tor 5 c++ exception-handling compiler-errors c++11
我正在读这个.我在代码块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';
}
}
Run Code Online (Sandbox Code Playgroud)
编译器错误:
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'
Run Code Online (Sandbox Code Playgroud)
这里出了什么问题?它是编译器错误还是C++11在代码块13.12 IDE中不完全支持?
请帮我.
您的编译器不支持std::bad_array_new_length.
谷歌的最高结果是code blocks 13.12:
codeblocks-13.12mingw-setup.exe文件包括来自TDM-GCC(版本4.7.1,32位)的GCC编译器和GDB调试器.
和GCC 4.7.1于2012年发布.根据这个邮件列表帖子,即使是主干 GCC也只支持std::bad_array_new_length自2013年以来.
从平分GCC参考手册,我们可以确定GCC 4.8.4没有它,但GCC 4.9.2呢.您链接的"在线编译器"运行GCC 4.9.2.
长话短说,你需要一个更新的海湾合作委员会.
"C++ 11支持"是一个非常广泛的术语,你会发现,直到最近,它基本上从未意味着完全支持C++ 11.例如,在GCC 4.9之前,根本不支持C++ 11正则表达式.
| 归档时间: |
|
| 查看次数: |
715 次 |
| 最近记录: |