Switching off optimization for a specific function in gcc 4.2.2

前端 未结 7 2230
执笔经年
执笔经年 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:37

    You could put the function in a separate file and compile that file without optimization but the better solution would be to figure out what is wrong with the code and fix it.

    One of the most common bugs that appears when optimization is enabled with gcc is with strict aliasing. Make sure all warnings are enabled and see if you get any warnings that might help you figure out what the problem is. If you can't figure it out, try to reduce the problem to a small, complete program and post it here.

提交回复
热议问题