🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #103

Request for information about setjmp/longjmp in g++

#103
From: a j cornah
Date: Thu, 23 Jul 1992 15:55
37 lines
2141 bytes
I have been looking at providing a similar feature to Ada EXCEPTIONs in
Modula-2, C and C++. What I need to do this reasonably cleanly is a
facility which works like "setjmp" but for one routine down:

a()
{
    if (b() != 0)
    {
        printf("Something happened\n");           <----------+
        return;                                              |
    } /* endif (b() != 0) */                                 |
    c();                                                     |
}                                                            |
                                                             |
int                                                          ^
b()                                                          |
{                                                            |
    return( MYsetjmp(buffer) );                              |
}                                                            |
                                                             |
c()                                                          |
{                                                            |
    longjmp(buffer); /* This returns to the code up here  ->-+
                      * rather than being wrong because b
                      * has already returned
                      */

In TURBO C++ I can obtain the source of the runtime library and modify the
setjmp code to save the value of the previous stack frame fairly easily.
I had a quick look at the source of g++ but it wasn't obvious whether I could
do the same and expect the same result.

Could you please tell me where to look for the code I need?

Thanks in anticipation of a reply

Tony Cornah
Technical Details
Message-ID: <12467.9207231555@acse.sheffield.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!osprey.shef.ac.uk!tony

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.help,comp.lang.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!osprey.shef.ac.uk!tony
From: tony@osprey.shef.ac.uk (a j cornah)
Subject: Request for information about setjmp/longjmp in g++
Message-ID: <12467.9207231555@acse.sheffield.ac.uk>
Sender: gnulists@ai.mit.edu
Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
Date: Thu, 23 Jul 1992 15:55:52 GMT
Lines: 38