可能重复:
Error: No previous prototype for function. Why am I getting this error?没有以前的原型?
我有我的头文件中原型的功能,但是Xcode中仍然给我警告No previous prototype for the function 'printBind'
。我以相同的方式创建了功能setBind
原型,但是在我的实现中我没有看到这个函数的警告。
CelGL.h
#ifndef Under_Siege_CelGL_h
#define Under_Siege_CelGL_h
void setBind(int input);
void printBind();
#endif
CelGL.c
#include <stdio.h>
#include "CelGL.h"
int bind;
void setBind(int bindin) { // No warning here?
bind = bindin;
}
void printBind() { // Warning here
printf("%i", bind);
}
虽然我现在明白错误的原因,但我并不真正了解此功能的用处。你什么时候可以定义一个带有不确定参数列表的函数?这与C++有什么关系?这是C++中的一个有用的功能吗? – sherrellbc 2017-12-04 13:52:58
您无法在C++中定义具有不确定参数列表的原型。在C++中,这意味着“没有参数”,而不是“不确定参数”。这个功能并没有像现实中的必要让步那么有用。当C被标准化时,整个庞大的代码库被编写成没有原型;它们在C中不存在。空括号符号全部都在标准前C中。如果违法,它会杀死新生的C标准。 C99仍然如此。 C11不太清楚,但保持不变。 – 2017-12-04 14:55:01