Go Down

Topic: Exception handling possible? (Read 3082 times) previous topic - next topic

Fuzzillogic

Since Arduino is based on C++, I've tried to use some exception handling, try {} catch () {}, etc. Unfortunately, the compiler refused, suggested that I should use the -fexceptions argument. In the GCC-docs I read that exception handling usually is enabled when using .cpp-files, so I tried to put the exception handling in a .cpp-file and include it in the main sketch. Too bad, I got the same compiler-error.

There are of course drawbacks to exception handling, as it leads to larger program code, so I can understand why it is disabled. But, apart from altering the Arduino-code, is there a way to enable exception handling? Or is there something that technically prevents exception handling somewhere?

mem

#1
Mar 13, 2008, 11:03 pm Last Edit: Mar 13, 2008, 11:04 pm by mem Reason: 1
The Arduino uses the avr-gcc compiler  and  according to this page "Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0."

Fuzzillogic

Ah, I was afraid it would be something like that :'(. Thanks for clearing it up tho!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy