Compilers and programming style (was Re: A question of style)

Art Boyne boyne at hplvli.HP.COM
Thu Jan 11 03:23:26 AEST 1990


scott at bbxsda.UUCP (Scott Amspoker) writes:
>bright at dataio.Data-IO.COM (Walter Bright) writes:
>>volatile int *p;
>>*p;		/* has side effects and must not be optimized away	*/

>Just curious - what kind of code should be generated for the above
>C fragment?

Simple: a read of the address pointed to by |p|, of whatever # of bits
an int is defined as on your particular machine.

The C code I write is mostly firmware built into instruments, and I
have repeatedly used this construct to force a read of a hardware
register, eg., to clear/disable an interrupt or other condition.

Art Boyne, boyne at hplvla.hp.com



More information about the Comp.lang.c mailing list