Thinking about this question from the original intents of keywords inline
and static
may be more helpful and clear.
- inline functions
The original intent of keyword inline
is to improve runtime performance, not for linkage/scoping as you said at the beginning. It is a hint that makes compiler attempt to generate code inline at the calling point rather than laying down the code once and calling it every time, which can avoid some overheads such as creating stack frame for the calls. In order to generate code inline, the function definition must be in scope, not just the declaration like ordinary functions. So, you should put the whole function definition in a header file foo.h
, and #include "foo.h"
when call it. These inline
functions in different translation units must be identical token-by-token to obey ODR(One Definition Rule). And these all inline
functions are just one single function, and so do static
variables in this inline
function.
- static functions
Keyword static
can be used to make functions local to a translation unit, namely that it gives them internal linkage. So if you put the whole function definition of foo()
into a header file foo.h
and mark it as static
, all translation units which #include "foo.h"
will have a local function foo()
. In other words, the functions foo()
in different translation units are not one single function, and neither do the static
variables in these static
functions.
- static inline functions
So you can guess functioins marked by both static
and inline
. These are not the same functions in different translation units like static
functions, but can give performance improvement by generate code inline.