Mic_chen

It is not the strongest of the species that survive, nor the most intelligent, but the one most responsive to change

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

问题背景:有些中断服务函数、寄存器操作(通过读取来清除标志,读取以后不使用,编译器优化等级较高时会自动优化)不想优化,而其他代码想优化。
问题:除了使用volatile,嵌入汇编,还有什么方法可以禁止编译器自动优化部分代码吗?
猜想:编译器会不会提供了类似一对指令来框住不需要优化的代码呢?
求大神解惑。

 

还是多看帮助文档:

 

posted on 2020-08-28 13:01  Mic_chen  阅读(770)  评论(0编辑  收藏  举报