Failed to catch c++ exceptions
Hey guys
I did convert my cubemx generated C project to a c++ project using SW4STM32 convert function.
However i’m not able to catch exceptions.
volatile int test = 0;
try
{
throw 1;
}
catch (const int& ex)
{
for (;;)
{
test++;
test += 99;
}
}
this very simple code always ends up in the termination handler instead of the catch phrase.
I’m using an STM32F429
I removed all noexception flags from the compiler and linker. I even added an exception flag, but still no success.
My GCC compiler flags:
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 ‘-Dweak=attributeweak’ ‘-Dpacked=attributepacked’ -DUSE_HAL_DRIVER -DSTM32F429xx -Og -g3 -pedantic -Wall -Wextra -Wconversion -fmessage-length=0 -fexceptions -ffunction-sections -c -fmessage-length=0 -MMD -MP
My G++ Compiler flags
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 ‘-Dweak=attributeweak’ ‘-Dpacked=attributepacked’ -DUSE_HAL_DRIVER -DSTM32F429xx -Og -g3 -pedantic -Wall -Wextra -Wconversion -fmessage-length=0 -fexceptions -ffunction-sections -c -fno-rtti -MMD -MP
Finished building: ../Core/Src/User/test.cpp
My g++ Linker Flags
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -fexceptions -Wl,--gc-sections -fno-rtti -o “SW4STM32_Exception_Test.elf” @”objects.list” -lm
Finished building target: SW4STM32_Exception_Test.elf
I tested the same code with True Studio. The exception catching works fine there. So the target is able to handle exceptions.
There must be some IDE setting with I missed.
Could you help me out please?