我的编译器(GCC)给我警告:

警告:函数的隐式声明

它为什么会来?


当前回答

When you get the error: implicit declaration of function it should also list the offending function. Often this error happens because of a forgotten or missing header file, so at the shell prompt you can type man 2 functionname and look at the SYNOPSIS section at the top, as this section will list any header files that need to be included. Or try http://linux.die.net/man/ This is the online man pages they are hyperlinked and easy to search. Functions are often defined in the header files, including any required header files is often the answer. Like cnicutar said,

您正在使用的函数的编译器没有看到 声明(“原型”)。

其他回答

我认为这个问题并没有百分之百的答案。我正在寻找缺少typeof()的问题,这是编译时指令。

以下链接将有助于了解情况:

https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Typeof.html

https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Alternate-Keywords.html#Alternate-Keywords

作为结论,尝试使用__typeof__()代替。还有gcc…-Dtypeof = __typeof__……能帮上忙。

When you get the error: implicit declaration of function it should also list the offending function. Often this error happens because of a forgotten or missing header file, so at the shell prompt you can type man 2 functionname and look at the SYNOPSIS section at the top, as this section will list any header files that need to be included. Or try http://linux.die.net/man/ This is the online man pages they are hyperlinked and easy to search. Functions are often defined in the header files, including any required header files is often the answer. Like cnicutar said,

您正在使用的函数的编译器没有看到 声明(“原型”)。

你需要在主函数之前声明你想要的函数:

#include <stdio.h>
int yourfunc(void);

int main(void) {

   yourfunc();
 }

不要忘记,如果函数中调用了任何函数,它们的原型必须位于代码中函数的上方。否则,编译器在尝试编译函数之前可能找不到它们。这将产生问题中的错误。

GNU C编译器告诉您,它可以在程序作用域中找到特定的函数名。尝试在头文件中将其定义为私有原型函数,然后将其导入到主文件中。