加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 有些优化编译器在读取时需要使用Volatile关键字?

发布时间:2020-12-16 10:19:36 所属栏目:百科 来源:网络整理
导读:用C思考说 the qualifier volatile tells the compiler “You never know when this will change,” and prevents the compiler from performing any optimizations based on the stability of that variable. 编译器执行的优化(除缓存之外)有哪些? 解决方
用C思考说

the qualifier volatile tells the
compiler “You never know when this
will change,” and prevents the
compiler from performing any
optimizations based on the stability
of that variable.

编译器执行的优化(除缓存之外)有哪些?

解决方法

最基本的优化是:将变量的值存储在CPU寄存器中.声明它是volatile会强制代码生成器始终从内存重新加载值,而不是使用寄存器中的缓存副本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读