home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.internals
- Path: sparky!uunet!mcsun!sun4nl!xelion!hans
- From: hans@xelion.nl (Hans Bos)
- Subject: Re: Question about longjmp ()
- Message-ID: <C0os9v.CG@xelion.nl>
- Organization: Xelion bv
- References: <C0JpMo.1rGr@austin.ibm.com> <1993Jan9.124323.13018@csie.nctu.edu.tw>
- Date: Mon, 11 Jan 1993 11:08:19 GMT
- Lines: 35
-
- cp78065@csie.nctu.edu.tw (Ji-Tzay Yang) writes:
-
- >Sivarama Subramanian (subra@bynar.austin.ibm.com) wrote:
- >: Hi folks,
- >: I have the following code segment.
- >: main ()
- >: {
- >: int i = 0;
- >: jmp_buf buf;
- >: setjmp (buf);
- >: printf ("%d\n", i);
- >: if ( i == 1 )
- >: exit;
- >: i = 1;
- >: longjmp (buf, 1);
- >: }
- >: My question is, should the value of i change or not.
-
- > After running the program, the value 'i' is changed, and it should be
- > changed.
-
- > But is there any consideration for 'i' to keep its orignal value?
-
- I believe that in ANSI C nothing is guaranteed for local variables
- after a longjmp, unless they are declared volatile.
-
- So if you use 'volatile int i = 0;', the value of i should be 1 after
- the longjmp.
-
-
- --
- Hans Bos domain : hans@xelion.nl
- Xelion BV uucp : ...!sun4nl!xelion!hans
- Postbus 88 phone : +31 15 622121
- 2600 AB Delft, The Netherlands fax : +31 15 621760
-