volatile

Chip Salzenberg chip at ateng.UUCP
Fri Apr 1 05:33:59 AEST 1988


In article <1988Mar29.004454.2867 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>Nobody is saying that the concept is not necessary in certain specialized
>situations.
>[...] the sort of code we're talking about isn't portable anyway.

What about signal handlers?

	/* begin example */

	volatile int hit = 0;

	int     foo();

	main()
	{
		signal(SIGINT, foo);
		while (!hit)
			;
		exit(0);
	}

	foo()
	{
		++hit;
	}

	/* end example */

Without volatile, you can't protect this program from being over-optimized.

>"Noalias must go.  This is non-negotiable."  --DMR
Definitely.
-- 
Chip Salzenberg                 "chip at ateng.UU.NET" or "codas!ateng!chip"
A T Engineering                 My employer's opinions are a trade secret.
       "Anything that works is better than anything that doesn't."



More information about the Comp.lang.c mailing list