Most C++ compilers allow for exceptions to be disabled. Is there a way to determine it from the code without using compiler-specific preprocessor macros, such as _CPPUNWIND for MSVC? Ideally at compile time.
Since WG21 in 2014, there is a recommended macro to use
__cpp_exceptions
It will have the value 199711 if exceptions are supported and the compiler conforms to C++98. Other similar feature macros are shown here.
No. Exceptions are part of C++. The fact that some compilers allow you to disable them is quite irrelevant and the Standard will not provide for you to detect if they're enabled- as far as it's concerned, they're always enabled. If you want to know about implementation-specific behaviour, the only way to go is to ask the implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With