#pragma volatile

Wayne A. Throop throopw at xyzzy.UUCP
Tue May 3 00:36:04 AEST 1988


>,>>> tneff at atpal.UUCP (Tom Neff)
>> karl at haddock.ima.isc.com (Karl Heuer)
>>>This is a wonderful feature ... but shouldn't we use
>>>        #pragma volatile(var1, var2, var3)
>>>instead of imposing a new keyword on the language grammar?
>>Unless you expand on this a bit, it's not as powerful.  I've actually used the
>>declaration "char volatile * volatile p;" (a volatile pointer to volatile
>>memory) -- would your proposal handle this?
> You're right, Karl, the #pragma approach wouldn't work for nested volatile
> references like your example, and I can't think of a graceful way to extend
> my proposal to deal with it either.

Not so fast, not so fast!  The obvious extension is to allow
declaration-like syntax in the pragma.  For example, to do Karl's
example from above, one would just say:

        char *p;
        #pragma volatile( p, *p )

... meaning that the pointer p is volatile, and so is the memory it
denotes.  In fact, come to think of it, this is more mnemonic than
scattering the "volatile" keyword around within the expression, and
calls out each case of volatility clearly and separately.

Not that I think that this would be adopted by X3J11 at this late
date... but it *does* mean that implementors could play around with
various volatile-like descriptors by tinkering with #pragmas, and avoid
reserving keywords up the wazoo.

--
You can lead a yak to water but you can't teach an old dog to make a
silk purse out of a pig in a poke.
                                        --- Opus
-- 
Wayne Throop      <the-known-world>!mcnc!rti!xyzzy!throopw



More information about the Comp.lang.c mailing list