__attribute__((optimize("-O2"))) doesn't work
Oleg Endo
oleg.endo@t-online.de
Mon Dec 22 21:39:00 GMT 2014
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
More information about the Gcc-help
mailing list