Pages: [1]   Go Down
Author Topic: Exception handling possible?  (Read 2742 times)
0 Members and 1 Guest are viewing this topic.
Enschede, the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.”
« Last Edit: March 13, 2008, 05:04:31 pm by mem » Logged

Enschede, the Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: