static inline function, in practice, is likely (but not necessarily) to be built in by some good optimizing compiler (for example, GCC when it is given -O2 ) on most of its call sites.
It is defined in the header file because it can be embedded on most call sites (possibly all). If it was just declared (and simply “exported”), then embedding is unlikely to happen (unless you compile and link to optimizations during linking , also known as LTO, for example, they compile and link to gcc -flto -O2 , and this significantly increases assembly time).
In practice, the compiler must know the body of the function in order to be able to embed it. Thus, a suitable place is to define it in some common header file (otherwise it can only be embedded in the same translation unit that defines it if you do not enable LTO) so that each translation unit knows the body of this built-in function.
It is declared static order to avoid several definitions (at the time of reference) in case the compiler did not enable it (for example, when you use its address).
In practice, in C99 or C11 code (with the exception of LTO, which I rarely use), I would always put short functions that I want to embed, like static inline definitions in shared header files.
Be sure to understand how and when the C preprocessor works . Note that you can, in principle (but that would be a very bad practice and disgusting style), avoid defining some static inline function in a common header file and instead copy and paste its identical definition into multiple .c files. (However, this may make sense for the generated .c files, for example, if you are developing a compiler that emits C code ).
FYI LTO is practically implemented by recent GCC compilers, embedding some internal compiler representation (a bit of GIMPLE ) in object files and redoing some “compilation” step - using the lto1 interface - during the “link”. In practice, the entire program is practically compiled “twice”.
(in fact, I always wondered why the C standardization committee did not decide instead that all explicitly inline functions are static)