C代码:如何检测重复的函数声明

blu*_*net 5 c compiler-warnings

makefile中是否有FLAG设置来检测重复的函数声明?

在头文件中找到重复的函数声明,但是即使FLAG设置为“警告为错误”,编译器也不会报告该声明。

这会带来任何隐性问题吗?

Tre*_*vor 0

重复的函数声明不是问题,那么为什么编译器需要将其报告为问题呢?

这种场景其实很常见:

来源1:

//definition
int func(void) {
...
}
Run Code Online (Sandbox Code Playgroud)

来源2:

//declaration
extern int func(void);
Run Code Online (Sandbox Code Playgroud)

来源3:

extern int func(void); //duplicate with source 2
Run Code Online (Sandbox Code Playgroud)