Skip to main content
Hoang_Tran
Associate III
June 23, 2020
Question

how to use try catch in CubeIDE 1.3

I am trying to use try catch with cubeIDE. But get the error when compiling.0693W000001rFTIQA2.png

This topic has been closed for replies.

4 replies

Nikita91
Lead II
June 23, 2020

The error message says "use -fexceptions". Did you do it?

Hoang_Tran
Associate III
June 23, 2020

thank you for reply!,how to use "use -fexception"?

TDK
June 23, 2020

Right click the project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU G++ Compiler -> Miscellaneous

Add the "-fexceptions" flag there.

Not sure how well it'll work, but it will compile.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Aurel
Associate
April 14, 2023

Hi everyone,

As this link is the first one when looking for "stm32 try catch", I'm adding some extra info.

The previous answer doesn't work for me.

When looking on other thread, it turns out that the problem is linked with the "-specs=nano.specs".

A solution that works for me was to choose "Standard C, Standard C++" for the runtime library:


_legacyfs_online_stmicro_images_0693W00000bi6RxQAI.png 

 And:


_legacyfs_online_stmicro_images_0693W00000bi6TKQAY.png 

And


_legacyfs_online_stmicro_images_0693W00000bi6UDQAY.png