qt+mingw 中缺少 std::runtime_error

发布于 2024-10-15 09:25:05 字数 647 浏览 2 评论 0原文

我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱要勇敢去追 2024-10-22 09:25:05

仅定义基 std::exception 类;如果您想要像 std::runtime_error 这样的子类,则必须包含 标头。

<exception> defines only the base std::exceptionclass; if you want child classes like std::runtime_error, you must include the <stdexcept> header.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文