I’ve tried __attribute__((optimize(“O2”))) and __attribute__((optimize((2))). All didn’t work. Chaoran > On Dec 22, 2014, at 3:39 PM, Oleg Endo <oleg.endo@xxxxxxxxxxx> wrote: > > On Mon, 2014-12-22 at 15:33 -0600, Chaoran Yang wrote: >> Hi all, >> >> I’m trying to use the __attribute__((optimize(“-O2”))) to mark a >> function that should always be optimized. But it doesn’t seem to work. >> I’ve tested both GCC 4.9.2 and 4.8.3, they both silently ignored the >> attribute. I’m wondering if I’m something super stupid that I’m not >> aware of. > > Try __attribute__((optimize("O2")) > > i.e. remove the leading '-'. > > See also: > https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes > > "Strings that begin with O are assumed to be an optimization option, > while other options are assumed to be used with a -f prefix. " > > Cheers, > Oleg > >