I understand that inline
by itself is a suggestion to the compiler, and at its discretion it may or may not inline the function, and it will also produce linkable object code.
I think that static inline
does the same (may or may not inline) but will not produce linkable object code when inlined (since no other module could link to it).
Where does extern inline
fit into the picture?
Assume I want to replace a preprocessor macro by an inline function and require that this function gets inlined (e.g., because it uses the __FILE__
and __LINE__
macros which should resolve for the caller but not this called function). That is, I want to see a compiler or linker error in case the function does not get inlined. Does extern inline
do this? (I assume that, if it does not, there is no way to achieve this behavior other than sticking with a macro.)
Are there differences between C++ and C?
Are there differences between different compiler vendors and versions?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…