I have a small C++ program that I need to use exceptions in. When I try to compile it I get the error:
error: exception handling disabled, use '-fexceptions' to enable
In my CMakeLists.txt I set the C++ version to 11 and enable -fexceptions
set(CMAKE_CXX_STANDARD 11)
...
target_compile_options (test PUBLIC -fexceptions)
Edit: for future readers this is for a Raspberry Pi Pico, and I found the answer.
After walking away from the problem for a while and coming back to it I found the answer. This was for a Raspberry Pi Pico; I didn't think that was important, but it turned out to be very important. Following the comment from t.niese I searched the sdk for -fno-exceptions and found in the sdk where exceptions were turned off. After reading the sdk documentation I added the line set(PICO_ENABLE_CXX_EXCEPTIONS 1) to my CMakeLists.txt file and that turned exceptions on.
Like what Mr.Samson suggest, but I use "set(PICO_CXX_ENABLE_EXCEPTIONS 1)".
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