Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all official Qt binaries built with -no-exceptions?

Tags:

c++

exception

qt

If I write

try {
    throw std::exception("Exception");
} catch (std::exception& ex) {
    qDebug("Game Over");
}

inside my main function (or anywhere else), my Qt application crashes. This effect has been described (5 years ago) in Exception handling doesn't work with Qt on Windows.

The original poster apparently solved the problem by reconfiguring and rebuilding the Qt SDK himself (explicitly enabling -exceptions), but I have a hard time believing that all Qt binaries are shipped with exceptions turned off and that everyone using exceptions must do this.

Could anyone point me to the place where this is documented, tell me whether this is true at all or what I'm doing wrong here?

I'm now on Qt 5.4.2 with MSVC2013, Win 7 (downloaded qt-opensource-windows-x86-msvc2013_opengl-5.4.2.exe from here).

like image 791
virt Avatar asked Oct 19 '22 08:10

virt


1 Answers

You're not doing anything wrong. Since Qt doesn't use exceptions, it'd be unnecessary overhead to have them enabled in the default Qt builds. Hence, on platforms that allow the exceptions to be disabled, they do in fact get disabled.

Generally speaking, you really need to compile Qt yourself. The prebuilt binaries are fine for exploration and student use, but if you're serious about using it in your product, or you need non-default configuration, you absolutely have to compile it yourself with the flags that you need.

like image 125
Kuba hasn't forgotten Monica Avatar answered Nov 11 '22 15:11

Kuba hasn't forgotten Monica