[LLVMdev] Conditions that cause Clang refuse inlining a function

Joerg Sonnenberger joerg at britannica.bec.de
Thu Sep 4 06:51:41 PDT 2014


On Thu, Sep 04, 2014 at 02:42:17PM +0300, David Sela wrote:
> I want to have some functions in my code inline so I use the *inline *
> keyword:
> 
> *inline void foo() {}*
> 
> On some functions the compiler inlines the function but it fails to do so
> on other functions and thus I get a linkage error:
> 
> *error: undefined reference to 'foo'*
> 
> What are the conditions that make the compiler refuse inline?

C99 says that inline is just a hint. You can force the compiler to emit
an instance by adding a separate prototype without inline, i.e. "void
foo();" in one file. You can also specify static, in which case a local
(outlined) version is used.

Joerg



More information about the llvm-dev mailing list