3

The following code prevents GCC compiler inline a specific function.

void __attribute__ ((noinline)) my_func() { ... } 

I wish to prevent gcc from inlining all functions. Can I do it without adding the attribute to all functions?

0

1 Answer 1

12

The global option to avoid inlining (when using -O2 or other optimisation flags) is -fno-inline

-fno-inline Do not expand any functions inline apart from those marked with the always_inline attribute. This is the default when not optimizing.

(source: https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Optimize-Options.html)

If you're doing this to reduce code size, I suggest that you throw in the -Os option (optimize for size)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.