On Sun, 12 Sep 2004 09:45:13 -0400
"Steven T. Hatton"
Looking over the ISO/IEC 14882:2003 discussion on signals I have the impression that signals and exceptions are intentionally placed on either side of the C/C++ fence. The support for signal handling in C++ is inherited from
of C. It seems pretty clear that any signal handling that would involve exceptions is "implementation defined". I would prefer to avoid implementation defined features as much as possible. OTOH, it would be nice if I could catch an exception when my program received some kind of signal. This seems to be one of the many damned if you do, damned if you don't
dilemmas of C++. If you do implement signal handling with exceptions, it breaks the C compatability objective. If you don't use exceptions you end up with C-style antiquated signal handling. Agreed. Use the standard exception mechanism in C++. It is very flexible, and there should be very few reasons to use C style signals at all, but signals are supported by the language, and are portable to the extent that they are supported by the standards.
One of the primary differences is that a signal handler runs in a
different context than does your regular code, whereas your exception
handler runs within the program's context. I would not use antiquated
with signals as signals are a lower level. C is essentially a medium
level language somewhere between assembler and what we might consider a
high level language.
--
Jerry Feldman