How to use " try  catch() " of C++ on KDS 3.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use " try  catch() " of C++ on KDS 3.0

1,914 Views
Fan_xy
Contributor III

Hello, Erich Styger  

 

KDS 3.0 , PE project or without PE project , kinetis K20X256vll7,  I want to use the exceptions detect  try catch() of C++,

 

could you tell me how to configure ?

The attachment is my project , and when i debug , it could not run in to the catch() , at the end, it show the error :

36960_36960.pngpastedImage_0.png

 

Thank !

Original Attachment has been moved to: k20dx256vl7_cpp_pe_test1.zip

Labels (1)
5 Replies

1,268 Views
carloshass
Contributor II

Hello fan,

I'm having trouble starting a C++ project with KDS 3, PE, using a kinetis KE06Z.

Can you help me with the steps or maybe posting a empty C++ project?

Regards,

CH

0 Kudos

1,268 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi fan xy,

The GNU toolchain that KDS 3.0.0 uses does not support exception handling, this is because the libstdc++ built along with newlib-nano have exception handling disabled. You can find more information on this link:

Question #230716 : Questions : GCC ARM Embedded

Hope it helps!

Best Regards,

Carlos Mendoza

Technical Support Engineer

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

1,268 Views
Fan_xy
Contributor III

Hello Carlos,

Thank for your reply.

And  how we can change the newlib-nano to newlib ? or change libstdc++ to another , which build along wiht newlib ?

Thank !

Fan

0 Kudos

1,268 Views
BlackNight
NXP Employee
NXP Employee

Hi fan,

if you remove --specs=nano.specs from the linker options, it will use the newlib.

Erich

1,268 Views
dmarks_ls
Senior Contributor I

Confirmed, disabling newlib-nano in the linker settings allows exceptions to be caught and handled.  It's rather necessary to do this with certain packages such as Cereal for serialization.  There is a code size penalty, of course, but if you're doing C++ applications with exception handling, you probably want to be running on a 1MB+ flash part anyway.

0 Kudos