Skip to content

volatile

The volatile is a type qualifier keyword used to prevent compiler optimizations on variable access. Volatile variables are read from and written to memory on every access, ensuring visibility of changes made by hardware or other threads.

Syntax

volatile var int32 hardware_register;

Example Code

volatile var int32 device_status = 0;

void poll_device()
{
    while (device_status is 0)
    {
        // wait for hardware to update device_status
    }
}