How do I force gcc to inline a function?

HaltingState picture HaltingState · Dec 5, 2011 · Viewed 61.2k times · Source

Does __attribute__((always_inline)) force a function to be inlined by gcc?

Answer

RCE picture RCE · Dec 5, 2011

Yes.

always_inline

Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level was specified.