volatile

The Prince Who Was A Thousand cquenel at pyramid.pyramid.com
Tue May 17 11:26:47 AEST 1988


In article <4025 at haddock.ISC.COM> karl at haddock.ima.isc.com (Karl Heuer) writes:
>
>There's a simpler refutation: the premise is false.  The signal() function is
>part of the standard library, and |volatile| is necessary for handlers of
>asynchronous signals.  Earlier I posted a strictly conforming program which
>contained some lines like:
>  #include <signal.h>
>  static volatile sig_atomic_t gotcha = 0;
>  static void catch(int signo) { gotcha = 1; }
>which argument has not been refuted to my knowledge.
>
>If |volatile| were removed, we'd either have to go back to the old rules
>(everything's volatile) or absorb its meaning into |sig_atomic_t|.


To the best of my knowledge, "volatile" is the only way of /guaranteeing/
that a (for instance) local variable will NOT be restored/affected by a
longjmp().  According to the version of the standard I was browsing.

--chris



More information about the Comp.std.c mailing list