Volatile type in ANSI C

Ken Montgomery kjm at ut-ngp.UUCP
Fri May 10 05:09:59 AEST 1985

>[henry at utzoo.UUCP (Henry Spencer)]
> ... It provides both.  "volatile int *foo;" declares a nonvolatile
>pointer to volatile; "int * volatile foo;" declares a volatile pointer
>to nonvolatile.  (Excuse me a moment while I barf over the syntax.)

What made me toss my cookies over this syntax is the apparent
inconsistency between the following:

1.  volatile int *foo;
2.  int * volatile foo;

In number 1, the _volatile_ immediately precedes the component of
the declaration corresponding to the volatile object (the _int_).
In number 2, the _volatile_ *follows* the corresponding component
(the _*_).  I find this inconsistency confusing; why doesn't the
_volatile_ always precede its corresponding component?  In other
words, number 2 would become:

2a. int volatile * foo;

I think this is a more consistent, and therefore superior, syntax.

The above viewpoints are mine.  They are unrelated to
those of anyone else, including my cats and my employer.

Ken Montgomery  "Shredder-of-hapless-smurfs"
...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!kjm  [Usenet, when working]
kjm at ut-ngp.ARPA  [for Arpanauts only]

More information about the Comp.lang.c mailing list