Is it possible to prevent the gcc compiler from inlining a particular function. If so, how?
Don't tell me to reduce the optimization level. I want all optimizations on, but mark a particular function to no be inlined by the compiler, just like volatile in case of variables.
And the reason I want to do this is because my function uses inline assembly defined labels, which gcc messes up when it inlines the function, as inlining causes gcc to create multiple instances of that label.
You should use the noinline
attribute
like this :
void the_method_you_dont_want_to_inline() __attribute__ ((noinline))
{
...
}
or in recent versions of GCC :
__attribute__((noinline)) void the_method_you_dont_want_to_inline()
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With