Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing std::runtime_error in qt+mingw

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.

like image 447
Eugene Loy Avatar asked Feb 01 '11 11:02

Eugene Loy


1 Answers

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

like image 161
CharlesB Avatar answered Oct 18 '22 10:10

CharlesB