4.4.4. Inlining functions across multiple files
The __inline keyword in C has the semantics of the standard C++ keyword inline. According to the C++ standard, an inline function is required to be identically defined in each translation unit in which it is used. Therefore, only objects with internal linkage can be inlined. It is not possible to link to an inline function in another file. In particular, extern functions are not inlined.
Because __inline has C++ semantics, declaring a function as __inline means that it cannot be called from another compilation unit. Therefore, a function declared extern __inline might not behave as you expect.
To make a function available for inlining across multiple files, you must:
place the function in a common header file, for example foo.h
mark the function as extern __inline
#include the header file in each file where the inline function is needed.
If the compiler decides not to inline the function in one or more cases, the function is compiled so that only one copy of it remains after linking.
Functions declared as __inline that are only called locally within a translation unit must never be placed in a header file. These functions cannot be shared, so multiple copies might exist after linking. Marking an inline function local to a compilation unit as static __inline instead of just __inline is a good coding style because it serves as a reminder to the programmer that __inline functions are implicitly static.
See Common group or section elimination in the Linker Guide for more information.