Optimization, volatile (was Re: volatile)

Rahul Dhesi dhesi at bsu-cs.UUCP
Thu May 5 06:29:38 AEST 1988


In article <536 at sol.warwick.ac.uk> cudcv at cu.warwick.ac.uk (Rob McMahon) writes:
<>It's been said before, but some people seem to have missed it ... how do
<>you use #pragma to specify all of:
<>
<>	volatile int *p;

#pragma volatile int *p

<>	int *volatile p;

#pragma int *volatile p

<>	volatile int *volatile p;

#pragma volatile int *volatile p

To decrease redundancy use a place-holder token where it says "int"
above:

     #pragma volatile ? *p
     #pragma ? *volatile p
     #pragma volatile ? *volatile p

Or, simplest of all, just choose one of these:

     #pragma volatile *p
     #pragma volatile p
     #pragma volatile p, *p

P.S.  I still think the "volatile" keyword is a better way for
specifying volatility than the pragma mechanism, but not because of the
argument that I'm refuting.  There are two more serious problems with
using pragma here, and at least the second one has been mentioned
before in this newsgroup:  (1) The presence of "volatile" changes the
semantics of the hypothetical C virtual machine;  (2) Vendors are free
to choose any syntax for their #pragma volatile, violating the
intuitively-obvious requirement that a universal concept ought to be
represented in a universal syntax.

Standard Weasel Clause:  The validity of argument (1) above depends on
the exact meaning of the phrase "semantics of the hypothetical C
virtual machine.
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi



More information about the Comp.lang.c mailing list