Switching off optimization for a specific function in gcc 4.2.2

前端 未结 7 2110
执笔经年
执笔经年 2020-12-16 16:24

Is it possible to switch off optimization of a specific function? A friend of mine has the problem that the gcc optimization makes some (unknown to me) µ-controller-code not

相关标签:
7条回答
  • 2020-12-16 16:58

    I can't say for certain but as far as I'm aware, there's no such possibility. However, optimization should never alter semantics of a well-defined code. The only thing that could happen here is that a variable gets inlined or that order of read/write gets changed.

    The first, and probably both problems can be addressed by declaring the variable(s) involved as volatile, thus showing the compiler that no assumptions about its content should be made, based solely on the program flow.

    0 讨论(0)
提交回复
热议问题