TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: Joseph W. Cheek 76264,142 (X)
from: James Jones 76257,562
date: 1990-05-03 06:18:24
subject: #3232-C process control

#: 3235 S12/OS9/68000 (OSK)
    03-May-90  06:18:24
Sb: #3232-C process control
Fm: James Jones 76257,562
To: Joseph W. Cheek 76264,142 (X)

What he's talking about is one of the so-called "type qualifiers" that are part
of the recently-adopted ANSI C standard.  The "volatile" qualifier is intended
to force the compiler to *not* do certain kinds of optimization, which aren't
appropriate for, to use the standard example, memory-mapped I/O stuff. 
Example: if one has a busy-wait loop of the form

while (*p == 0) ;

an optimizing compiler would be within its rights to peform code motion on the
apparently unchanging value of *p and transform the code into

if (*p == 0) {for (;;) ;}

testing *p only once.  In ANSI C, if p were declared to have the type "pointer
to volatile int," the compiler would be informed that unknown external events
could change the value of *p, so that it is improper to consider *p as not
changing, even though the code contains nothing that would change it.

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.