Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
553 views
in Technique[技术] by (71.8m points)

c - Switching off optimization for a specific function in gcc 4.2.2

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 work. We know which functions it is, but we have no clue of the code itself so the easiest and safest way would probably be to just switch it off for the whole function.

Sadly http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html shows that there is a an optimize function attribute / pragma, but it requires gcc 4.4, which we do not have.

thanks in advance

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If the pragma won't work for you, try splitting the function into its own file, and then compile that file without the optimisation flag set.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...