volatile

Barry Margolin barmar at think.COM
Wed Mar 30 12:38:40 AEST 1988


In article <134 at wyse.wyse.com> mikew at wyse.UUCP (Mike Wexler) writes:
>I would disagree that is isn't possible to write portable code that requires
>volatiles. An example(possibly the only one), is the use of System V
>or Berkeley shared memory.  With either of these you can have volatile
>values in portable(At least to similar Unix systems) programs.  Given
>this it might be useful for the Posix standard to require the C compiler
>to support volatile or a volatile pragma.

But such programs are NOT portable.  A program using System V shared
memory is not portable to a BSD system and vice-versa.  And none of
them are portable to non-Unix systems.

As you yourself implied in your last sentence, the right place for
such a requirement is in the Posix standard, not the C standard.  And
the mechanism that can be used for this is #pragma.  The C standard
doesn't specify the format of particular pragmas (whether this is wise
is debatable), but Posix already requires various extra C features
(for example, I believe it adds things to include files that are
specified in the C standard), so it could also require that compilers
implement a particular set of pragmas with a given syntax.


Barry Margolin
Thinking Machines Corp.

barmar at think.com
uunet!think!barmar



More information about the Comp.lang.c mailing list