Pregunta de entrevista de MaxLinear

Why do we use volatile in C

Respuestas de entrevistas

Anónimo

24 may 2011

Elaborating on WHY it needs to be volatile is that it's basically a hint to the compiler not to cache the data / variable in a register as it will most likely be modified externally.

5

Anónimo

21 mar 2010

The variable which needs to be updated very often then that variable should be declared as volatile. The variables that need to updated based on interrupt then that variable should be defined as volatile. Ex:time, whenever interrupt occurs for time the clock tick increments which will be declared as volatile.