I was reading Stroustrup’s c++ FAQ and I noticed that, at one point, he had a writeonly qualifier in the language. After some discussion, a colleague and I could only come up with one purpose – side effects, specifically in the case of some memory mapped IO. Is there any other legitimate usage for a writeonly qualifier?
Share
The
write-onlyqualifier would be useful for hardware registers since reading from awrite-onlyregister would lead to undefined behavior or subtle run-time errors. You can use a#definesuch as#define write-onlyand then apply this to a register like,special_register write_only UTXBUF;There is a blog post at EE Times on How to Enforce write-only access.