Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
据我所知,C 内联函数体应该在 .h 文件中定义,因为如果在 .c 文件中定义了函数体,它会导致错误“使用但从未定义的函数名”。
这是常规方式吗?或者如何在 .c 文件中定义内联函数体?
每个.c文件都独立编译成.o输出。如果你在一个.c文件中定义了内联函数,其他源文件看不到这个函数,所以不能内联。
.c
.o
因此,内联函数应该在.h文件中以允许共享代码。
.h