volatile

Lawrence V. Cipriani lvc at tut.cis.ohio-state.edu
Wed Mar 30 14:15:01 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. ...

I might not understand volatile correctly but this might also be an
example:

	volatile int customer_changeable_var = 0;

	main( )
		...

	if (customer_chageable_var != 0)
	{
		...
	}

If the volatile were dropped off, the compiler would be free to
optimize out the "impossible" code.  A customer changeable global
variable is a handy way for implementing optional features that
customers may or may not want; especially in programs that should
avoid disk i/o.

-- 
Larry Cipriani, AT&T Networks Systems (day) Ohio State University (night)
Domain: lvc at tut.cis.ohio-state.edu
Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (weird but right)



More information about the Comp.lang.c mailing list