4 ms·
I would expect volatile and const to be mutually exclusive.
by cryptonector 3y ago
I would expect volatile and const to be mutually exclusive.
- Someone 3y agoFor C++, you would be wrong. You can use it for variables that your code won’t change (hence const), but that can change due to outside events and hence can’t be cached in a register (hence volatile) See https://www.embedded.com/combining-cs-volatile-and-const-keywords/ https://www.embedded.com/combining-cs-volatile-and-const-key... for examples, https://en.cppreference.com/w/cpp/language/cv https://en.cppreference.com/w/cpp/language/cv for a more formal description.
- cryptonector 3y agoYes, I'm aware, and thus I said "would". But I wouldn't make use of this without first reading the spec on that very carefully. Thankfully I've not needed this.
- Rucadi 3y agoIn a Memory Mapped device, a read can trigger side effects (in fact, I worked a lot with that), so is not only is about memory.