<p>What does the <code>volatile</code> keyword do? In C++ what problem does it solve?</p>

<p>In my case, I have never knowingly needed it.</p>

```
volatile
```
is needed when developing embedded systems or device drivers, where you need to read or write a memory-mapped hardware device. The contents of a particular device register could change at any time, so you need the
```
volatile
```
keyword to ensure that such accesses aren't optimised away by the compiler.