How to prevent feature optimization

I am optimizing all the code, but I do not want a certain function to be optimized, say, for debugging purposes. Is there a way to do this on the gcc 3.4+ compiler?

+3
source share
1 answer

The easiest way: put the function in your own compilation unit, compile this flag without optimization flags.

Recent versions of gcc (4.4+, I think) have an attribute to control optimization for each function, use

__attribute__((optimize(0))) 

for disable optimization function

+12
source

Source: https://habr.com/ru/post/1718838/


All Articles