Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!cs.utexas.edu!uunet!mcsun!ukc!axion!tigger!raph From: raph@tigger.planet.bt.co.uk (Raphael Mankin) Newsgroups: comp.lang.c Subject: Write-only variables Message-ID: <561@tigger.planet.bt.co.uk> Date: 14 Sep 89 09:50:57 GMT Reply-To: raph@tigger.UUCP (Raphael Mankin) Organization: RT5111 British Telecom. Research Labs., Martlesham Heath. Lines: 22 How does one declare write-only variables in C? This is not as silly a question as it sounds. I can declare read-only variables as 'const' or 'const volatile'; the latter corresponds to a read-only register in a memory-mapped device. Now, 'const volatile' sounds like a contradiction in terms, but that is how it is done. If I have a write-only device register it would be a write-only variable to C. BTW some devices behave differently when one reads them from when one writes them. Some UARTs, for instance, (6850 I think) map the status register (read only) to the same location as a control register (write only). One tells a compiler that the value it just wrote to a location is ALWAYS different from the value it will read back by the use of 'volatile'. 'Volatile' is not quite strong enough here, but it is what we have. Raphael Mankin raph@planet.bt.co.uk -- Raphael Mankin raph@planet.bt.co.uk