volatile

haug at cc.Columbia.NCR.COM haug at cc.Columbia.NCR.COM
Wed Oct 25 12:05:42 AEST 1989


I understand the usage of volatile to indicate that a value may change for
reasons that are not necesarily apparent (hardware registers, interrupts, etc)
and so must be read from memory each time they are referenced.  My question is:
must the value be written each time it is assigned.  The reason I ask is I was
recently playing with a piece of hardware that upon second and subsequent writes
to the register actually went to an alternate register.  Thus for initialization
there were two successive assignments to the same variable.  Many current
compilers would discard the first assignment since its effect is wiped out by
the second.  Does volatile protect this?  If not, is there any method to
accomplish my goal reliably and portably?

Please e-mail response and I will sumarize.

			Share and Enjoy!

			      Brian (haug at Columbia.NCR.COM)



More information about the Comp.std.c mailing list