我已经阅读了一些与此主题相关的帖子,但无法彻底理清我的疑问.这可能是一个非常天真的问题.
我有一个头文件inline.h和两个翻译单元main.cpp和tran.cpp.
代码详情如下
#ifndef __HEADER__
#include <stdio.h>
extern inline int func1(void)
{ return 5; }
static inline int func2(void)
{ return 6; }
inline int func3(void)
{ return 7; }
#endif
Run Code Online (Sandbox Code Playgroud)
#define <stdio.h>
#include <inline.h>
int main(int argc, char *argv[])
{
printf("%d\n",func1());
printf("%d\n",func2());
printf("%d\n",func3());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
//(note that the functions are not inline here)
#include <stdio.h>
int func1(void)
{ return 500; }
int func2(void)
{ return 600; }
int func3(void) …Run Code Online (Sandbox Code Playgroud)