qt+mingw 中缺少 std::runtime_error
我尝试使用 Qt(4.6.3) + MinGW 编译以下代码:
#include <QtCore/QCoreApplication>
#include <exception>
int main(int argc, char *argv[])
{
throw std::runtime_error("");
QCoreApplication a(argc, argv);
return a.exec();
}
...并收到此错误:
..\untitled11\main.cpp:6: error: 'runtime_error' is not a member of 'std'
从头开始创建项目(控制台应用程序),pro 文件:
QT += core
QT -= gui
TARGET = untitled11
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
尝试使用 Qt+MSVC2008 编译器编译此代码 -工作正常。
这是一个标准异常,不知道为什么会丢失。
I've tried to compile the following code using Qt(4.6.3) + MinGW:
#include <QtCore/QCoreApplication>
#include <exception>
int main(int argc, char *argv[])
{
throw std::runtime_error("");
QCoreApplication a(argc, argv);
return a.exec();
}
... and got this error:
..\untitled11\main.cpp:6: error: 'runtime_error' is not a member of 'std'
Project created from scratch(console application), the pro file:
QT += core
QT -= gui
TARGET = untitled11
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
Tried to compile this using Qt+MSVC2008 compiler - works fine.
This is a standard exception, have no idea why is missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅定义基std::exception
类;如果您想要像std::runtime_error
这样的子类,则必须包含
标头。<exception>
defines only the basestd::exception
class; if you want child classes likestd::runtime_error
, you must include the<stdexcept>
header.