Including Throwing Exceptions classes to NOEXCEPT project
-
From https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html:
If you might have some code that throws, you shouldn't use -fno-exceptions. If you have some code that uses try or catch, you shouldn't use -fno-exceptions.
So the answer is no
-
@Kofr For example of the exterme case, I'm building QtWebKit with disabled exceptions but one file enables them to catch possible std::bad_alloc from Qt:
https://github.com/annulen/webkit/blob/qtwebkit-5.212/Source/WebCore/PlatformQt.cmake#L194
In qmake it's impossible to set flags for one file, so you will need to split exception-enabled code into (static) library
-
@Konstantin-Tokarev I still see the problem. If you build exception throwing code into .lib or .a there is still header which is not noexcept. Is it ok for the compiler to work with such header and lib or the problem is real?
-
@Kofr Seems like you didn't understand problem yet. You need to separate catching code into the library, not only throwing.
So you basically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.
-
(I hope you are not going to ignore errors from cryptographic library)
-
@Konstantin-Tokarev said in Including Throwing Exceptions classes to NOEXCEPT project:
sically need a wrapper that will call trowing functions and catch all exceptions, then use this wrapper in noexcept code.
thx, now I got the trick
-
Also, I don't know if this trick works with MSVC, didn't try that yet
-
@Konstantin-Tokarev Visual Studio allows per-file compile flags so the trick should be redundant
-
@VRonin I don't doubt that Visual Studio can do this, my poins are
- qmake doesn't have native way to set source-specific flags, you need to create your own custom target with all gory details of building C++ file, so it's much easier to move it into library
- I don't know if mixing EH flags in the same binary is reliable with MSVC