J3/99-261R1 Date: 30 Nov 1999 From: Dick Hendrickson Subject: Simpler Example of Volatile References: 99-252, issue 34 [438], issue 83 [7] Replace section C.2.3 with a simpler example of use of the VOLATILE attribute. This will eliminate the need for Copyright notices and be easier to follow. Also add a reference to the C standard in chapter one. Edites: Replace page 438, lines 21-53 and page 439 lines 1-49 with: The following example shows the use of a variable with the VOLATILE attribute to communicate with an asynchronous process, in this case the operating system. The program detects a user keystroke on the terminal and reacts at a convenient point in its processing. The VOLATILE attribute is necessary to prevent an optimizing compiler from storing the communication variable in a register or from doing flow analysis and deciding that the EXIT statement can never be executed. Subroutine Terminate_Iterations Logical, VOLATILE :: user_hit_any_key ... ! Have the OS start to look for a user keystroke and set the variable "user_hit_any_key" ! to TRUE as soon as it detects a keystroke. This pseudo call is operating system dependent. Call OS_BEGIN_DETECT_USER_KEYSTROKE( user_hit_any_key) user_hit_any_key = .false. !this will ignore any recent keystrokes print *, " hit any key to terminate iterations!" Do I = 1,100 ..... ! compute a value for R print *, I, R if (user_hit_any_key) EXIT Enddo ! Have the OS stop looking for user keystrokes Call OS_STOP_DETECT_USER_KEYSTROKE End Subroutine Terminate_Iterations Page 7, line 6, Add ISO/IEC 9899:1990, Information Technology - Programming Languages - C We refer to ISO/IEC 9899:1990 as the C standard. Page 7, lines 7-11, change the text of note 83 to When the forthcoming standard revision of the C standard has been published, the reference to ISO/IEC 9899:1990 should be updated in 2 places above.