Go Down

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


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?


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."


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

Go Up