[cfe-dev] always_inline and noinline attributes
Luís Marques
luismarques at gmail.com
Wed Jul 23 06:24:22 PDT 2008
Hi,
> 1) A function marked always_inline must always be inlined. This means it
> cannot be used in other way, so taking the address of an always_inline
> function is an error.
I have been thinking about this. Would it be too hard to make this
rule more flexible, so that for instance the following case would be
possible:
const int CONFIG_OPTIMIZED = 1;
int foo(int x) __attribute__ ((always_inline))
{
if(CONFIG_OPTIMIZED)
return foo_optimized(x);
else
return foo_fast(x);
}
Taking the address of foo() would return the address either
foo_optimized or foo_fast. Of course this could be done with the
preprocessor, but using the preprocessor has several disadvantages (in
terms of maintenance).
--
Luís Marques
More information about the cfe-dev
mailing list