Handling exceptions in C++ has a few implicit restrictions at the language level, but you can get around them in some instances. Learn ways to make exceptions work for you so you can produce more reliable applications.
Handling exceptions in C++ has a few implicit restrictions at the language level, but you can get around them in some instances. Learn ways to make exceptions work for you so you can produce more reliable applications.
One warning about using exceptions from signal handlers: it only works for syncronous signals like FPE, ILL or SEGV. Async signals like INT, TERM or ALRM will not work because the stack frame isn’t guaranteed to be right. There are system-specific ways to make it work if you really need it, there’s some code that does it in GCJ.
Exceptions in C++ are powers of the dark side. They are easy and strong, but horrible unreliable and unusable for anything cross-platforms.
And besides they slow down everything to a crawl. Once there was a 10% gain by giving g++ -fno-exceptions. Today it is only a penalty for the fools who use them.
When used correctly, they can do a lot of good for making things both easier to read, less source code to deal with, and make things more reliable. However, they shouldn’t be used except in “exceptional” cases involving resource problems or real flaws. ANTLR is an example of a library that uses them for normal flow control, which seems sick and wrong to me.
If you hate exceptions, what made you read an article titled C++ exception-handling tricks for Linux?
I love exceptions, in C++, Java, Python and Perl (eval/die in Perl). I guess we’d better never work together in software design.
If you both have valid reasoning, it’s a good reason why you should work together. Maybe in the end you’ll both be better off..
If you love exceptions try out uC++. You cannot beat the exception handling capabilities here:
http://plg.uwaterloo.ca/~usystem/uC++.html
And don’t forget concurrent programming and exception handling . It’s all right there!
And besides they slow down everything to a crawl. Once there was a 10% gain by giving g++ -fno-exceptions. Today it is only a penalty for the fools who use them.
I thought that only with the MS C++ compilers you pay a performance penalty for using exceptions even when not throwing them. Otherwise, non-thrown exceptions are supposed to be “free”.