[英]warning: implicit declaration of function
I'm programming in C and my gcc compiler gives me the following warning in my function call in mySedondFile.c:
我正在用C编程,我的gcc编译器在mySedondFile.c:
函数调用中给了我以下警告mySedondFile.c:
implicit declaration of function 'func'
The function prototype is declared in myfile.h
as: 函数原型在myfile.h
声明为:
void func(char*);
Function definition is in myfile.c
函数定义在myfile.c
void func(char*x);
mySecondFile.c
contains: mySecondFile.c
包含:
#include "myfile.h"
func("Hello");
I'm missing why this would complain. 我想念为什么会抱怨。
That error is emitted because func
has not been declared at the point at which you call it. 发出该错误是因为在func
尚未声明func
。
It sounds like your header files aren't quite as you describe. 听起来您的头文件并不像您所描述的那样。 Perhaps there is some conditional code. 也许有一些条件代码。 Maybe you have a header guard that is not working right. 也许您有一个无法正常工作的标题保护。 Another possibility is that you have got a letter case error and declared the function Func
but called it with func
. 另一种可能性是,您遇到了字母大写错误,并声明了Func
函数,但使用func
对其进行了func
。 Very hard to say without seeing the actual files but you need to look for a reason why func
is not declared in the mySecondFile.c
translation unit. 在没有看到实际文件的情况下很难说,但是您需要寻找在mySecondFile.c
转换单元中未声明func
的原因。
To illustrate this a little more clearly, the following code: 为了更清楚地说明这一点,下面的代码:
int main(void)
{
func("Hello");
return 0;
}
results in this warning: 导致此警告:
prog.c: In function ‘main’:
prog.c:3: warning: implicit declaration of function ‘func’
which is exactly as you report. 完全符合您的报告。
According to your description, your code includes a header file which declares func
. 根据您的描述,您的代码包括一个声明了func
的头文件。 The compiler begs to differ with you and it remains for you to work out why func
is not declared. 编译器可能会与您有所不同,并且仍然需要弄清楚为什么未声明func
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.