How to properly inline and use an inline function in C99? (build fails)

泪湿孤枕 提交于 2019-11-29 10:32:33
Jens Gustedt

Probably you wouldn't have that error when you compile with -O2 or so.

Inline function definitions should go in header files and an extern inline declaration should go in one compilation unit. Do

inline void a(void){
 // empty
}

// in just one .c file
#include "the-file.h"
extern inline void a(void);

BTW, declaring a without void is not a prototype.

There's no function prototype, that's all, so the function signature is inferred, and inferred wrong. Add "void a();" to the top of the file, and you're all set.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!