volatile keyword - what does it mean?

Kenstir kenc at suntan.viewlogic.com
Wed Jun 19 10:31:24 AEST 1991



I have a (char *) variable that I'm trying to protect
across a longjmp, so I want to tell GCC not to put it in
a register.  I believed that `volatile' did this, and it works
for integral types, but for pointer types, "gcc -O -Wall" still gives me

    foo.c:666: warning: variable `mbuf' may be clobbered by `longjmp'

It seems that GCC is assuming that `mbuf' is a pointer to a volatile
object, but that doesn't do me any good.  Can someone explain what
exactly the following two declarations mean and the difference between them?

    volatile int i;
    volatile char *mbuf;

I have looked at K&R 2, and also the GCC documentation.
Thanks very much for any light you can shed on the subject.

-- 
Kenneth H. Cox
Viewlogic Systems, Inc.
kenc at viewlogic.com
..!{harvard,husc6}!viewlogic.com!kenc



More information about the Comp.lang.c mailing list