Is it sufficient to declare an instance of a structure-typed variable as volatile (if its fields are accessed in re-entrant code), or must one declare specific fields of the structure as volatile?
Phrased differently, what are the semantic differences (if any) between:
typdef struct {
uint8_t bar;
} foo_t;
volatile foo_t foo_inst;
and
typedef struct{
volatile uint8_t bar;
} foo_t;
foo_t foo_inst;
I recognize that declaring a pointer-typed variable as volatile (e.g. volatile uint8_t * foo) merely informs the compiler that the address pointed-to by foo may change, while making no statement about the values pointed to by foo. It is unclear to me whether an analogy holds for structure-typed variables.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…