Static inline considered harmful

12 Dec 2020 - John Z. Li

The worst thing about the inline keyword in the C programming language is its name, because it has little to do with the compilation optimization technique called inclining, that is in-place code substitution of function calls. Modern compilers inline function calls as they see proper for performance reasons, with or without the inline keyword. What the keyword really means is as below:

If inline functions are used correctly, the programmer have all the above guarantees. However, if they are marked as static inline instead, we have problems:

To sum up, do not mark your function as static inline. If you mean static, use static. If you mean inline, use it properly.