Ambiguous C?
Piet van Oostrum
piet at cs.ruu.nl
Fri Apr 28 19:17:09 AEST 1989
In article <111 at ssp1.idca.tds.philips.nl>, roelof at idca (R. Vuurboom) writes:
`#define SCUCMD 0
`#define SCU_BDID 0x2000 /* bit 14 */
`
`error()
`{
` if ( (*(int *)(SCUCMD)) & SCU_BDID )
` ;
`}
In article <10136 at smoke.BRL.MIL>, gwyn at smoke (Doug Gwyn) writes:
`state of the bit is. To force a longword access, it suffices to copy
`the addressed object into an external longword, because the compiler
`cannot know what other use might be made of its contents (by other
`independently-compiled modules) and must therefore pick up the whole
Another simple way is to put the bit to be extracted in a variable, so the
compiler doesn't know to optimize it:
long SCU_BDID = 0x2000 /* bit 14 */
This has the advantage that it also works for bit sets.
--
Piet van Oostrum, Dept of Computer Science, University of Utrecht
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
Telephone: +31-30-531806. piet at cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)
More information about the Comp.lang.c
mailing list