AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only

Howto throw C++ exceptions on C library signals

  • 1.  Howto throw C++ exceptions on C library signals

    Posted Thu January 18, 2007 05:41 PM

    Originally posted by: SystemAdmin


    C++/C users,

    When calling a C library from C++, division by zero or invalid dereference,
    aborts with a signal (e.g. SIGSEGV).

    I understand that ANSI C does not support exceptions,
    but I vaguely remember a simple (<10 line) idiom that would throw an exception
    on a C/ANSI/POSIX signal.

    This provided an opportunity to save debugging info regarding the C++ state
    at the time of the call,
    and at least directed debugging toward the errant library caller.

    My swiss-cheese memory associates the idiom with sigaction(2).

    Can anyone point me to this idiom?

    TIA,
    #AIX-Forum