在 编译.c文件并生成lib 文件,最后在link 该lib 文件生成最终的elf 文件,发现提示 inline函数指向的function 未定义, 通过readelf .o 文件确实显示未定义,所以可以判断为inline 函数没有展开了。
check Gcc User Mannual : 默认编译优化选项-O0, 默认不内联,可使用__attribute__((always_inline)) 强制内联。
-O0 Reduce compilation time and make debugging produce the expected results.
This is the default.
GCC does not inline any functions when not optimizing unless you specify the
‘always_inline’ attribute for the function, like this:
/* Prototype. */
inline void foo (const char) __attribute__((always_inline));