home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / g / help / 1038 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  2.1 KB

  1. Xref: sparky gnu.g++.help:1038 comp.lang.c++:11457
  2. Newsgroups: gnu.g++.help,comp.lang.c++
  3. Path: sparky!uunet!cis.ohio-state.edu!osprey.shef.ac.uk!tony
  4. From: tony@osprey.shef.ac.uk (a j cornah)
  5. Subject: Request for information about setjmp/longjmp in g++
  6. Message-ID: <12467.9207231555@acse.sheffield.ac.uk>
  7. Sender: gnulists@ai.mit.edu
  8. Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
  9. Date: Thu, 23 Jul 1992 15:55:52 GMT
  10. Lines: 38
  11.  
  12. I have been looking at providing a similar feature to Ada EXCEPTIONs in
  13. Modula-2, C and C++. What I need to do this reasonably cleanly is a
  14. facility which works like "setjmp" but for one routine down:
  15.  
  16. a()
  17. {
  18.     if (b() != 0)
  19.     {
  20.         printf("Something happened\n");           <----------+
  21.         return;                                              |
  22.     } /* endif (b() != 0) */                                 |
  23.     c();                                                     |
  24. }                                                            |
  25.                                                              |
  26. int                                                          ^
  27. b()                                                          |
  28. {                                                            |
  29.     return( MYsetjmp(buffer) );                              |
  30. }                                                            |
  31.                                                              |
  32. c()                                                          |
  33. {                                                            |
  34.     longjmp(buffer); /* This returns to the code up here  ->-+
  35.                       * rather than being wrong because b
  36.                       * has already returned
  37.                       */
  38.  
  39. In TURBO C++ I can obtain the source of the runtime library and modify the
  40. setjmp code to save the value of the previous stack frame fairly easily.
  41. I had a quick look at the source of g++ but it wasn't obvious whether I could
  42. do the same and expect the same result.
  43.  
  44. Could you please tell me where to look for the code I need?
  45.  
  46. Thanks in anticipation of a reply
  47.  
  48. Tony Cornah
  49.  
  50.