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
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.