Please don't redirect me to there answers here - I have read them, and other answers all over the internet, including the standard, but am still confused (mostly, I think because of the overlap of technical words, english words, and language keywords).
Let me get this straight, in C99, for functions:
static: Don't produce any external symbols
extern (implicit): If there are no definitions in this translation unit, the compiler produces a reference that is resolved during linking
Now with inline. As far as I can tell, the issue is complicated due to the fact that the compiler may choose to inline, or not.
- If the compiler decides to inline, clearly the implementation must be visible at compile-time
- If the compiler decides not to inline, what function gets linked, and in which translation unit does that code live?
I can see this being answered in two different ways:
- If a compiler decides not to inline a function at some call site, then non-inline object code is generated inside the same translation unit. No external symbols are exported for this.
- If a compiler decides not to inline a function at some call site, then this behaves as a normal function, and there must be one translation unit that exports an external symbol and contains object code implemnitating the function.
static inline seems to be the answer to #1:
- If the compiler decides to inline a static inlinefunction, then go for it. Thestaticstorage specifier is consistent with it's use with non-inline functions in that no external symbols are produced. Since this is the case, if the compiler decides to inline astatic inlinefunction at every call site within a translation unit, it need not generate stand-alone object code.
- If the compiler decides not to inline a static inlinefunction at some call site, then it can generate stand-alone object code inside the translation unit, and no external symbols will be exported for it.
As far as I can tell, extern inline/inline is the answer to #2:
- All inline(withoutexternorstatic) behave like #2. If the compiler doesn't actually inline them, then at link time an external implementation needs to be linked-in.
- The translation unit that actually exports a symbol to link against
must declare as extern inline. I think this is what's most confusing, since theexternkeyword for normal functions behaves in almost the exact opposite way
Is this correct?
Relevant links, yet still leave fuzzy corners:
Is “inline” without “static” or “extern” ever useful in C99?
 
    