Volatile variable

前端 未结 6 1529
梦谈多话
梦谈多话 2020-12-25 15:12

Where is a volatile variable stored in the program memory(in which section) ?

6条回答
  •  滥情空心
    2020-12-25 15:48

    The volatility of a variable does not change the place in which a variable is stored. What it changes is the semantics around how it is accessed with respect to reads and writes.

    I do not believe the C standard says anything about the implementation of volatile. But typically, volatile guarantees release semantics for write operations on a variable and aquire semantics on read operations of a variable. This will not be true for every implementation though and you should read up on what your specific compiler guarantees

提交回复
热议问题