C++ – “Optimize” attribute directive is ignored

“Optimize” attribute directive is ignored… here is a solution to the problem.

“Optimize” attribute directive is ignored

I have a project with the optimization of all files set to “-OS” via the gcc command line flag. However, I want to disable the optimization of some methods in one of the source files. To do this, I tried to specify optimization properties for these methods. However, gcc says it ignored the optimize attribute during the build. Does anyone know what the problem is?

class C 
    int __attribute__((optimize("-O0"))) foo();

I’m using gcc version 4.4.3.


Delete -. It is not required (or may not be expected).

Related Problems and Solutions