gcc关于内联函数的问题
之前没注意过这个问题,今天才发现的。刚刚用gcc编译了一个小程序,代码很简单,如下:
程序代码:#include<stdio.h>
#include <time.h>
inline void PrintString(char * str);
int main(void)
{
PrintString("This is the first line info.");
PrintString("This is the second line info.");
return 0;
}
inline void PrintString(char * str)
{
printf("%s\n", str);
}问题是不论生成的汇编代码,还是反汇编后的汇编代码都看不出内联的迹象。
编译命令如下:
gcc test.c -o test -O
gcc test.c -o test -O2
这两个命令编译后,结论都是一样,没有内联的迹象。
难道是我哪个地方写错了?




