错误:没有previous原型的功能。为什么会出现这个错误? [英] Error: No previous prototype for function. Why am I getting this error?
问题描述
// screen.h
的#ifndef screen_h
#定义screen_h#定义MAC 1
WIN的#define 2
#定义LNX 3#IFDEF平台
#民主基金平台
#万一的#define PLATFORM MAC无效screen_init();#万一
// screen.c
的#include<&string.h中GT;
#包括LT&;&stdlib.h中GT;#包括screen.h#如果平台== MAC#包括LT&;&curses.h里GT;无效screen_init(){
删除();
}#万一
我不明白为什么它没有看到screen.h我的原型
任何建议/提示是AP preciated!
ISO / IEC 9899:TC2 - 6.2.1.2:结果
函数原型是声明了它的类型参数的函数的声明。
块引用>在函数声明空参数列表表明,参数的数量和类型是不知道。必须明确指出的功能通过使用
无效
关键字不带任何参数。否则,你的函数声明不能算作有效的雏形。无效screen_init(无效);
// screen.h
#ifndef screen_h #define screen_h #define MAC 1 #define WIN 2 #define LNX 3 #ifdef PLATFORM # undef PLATFORM #endif #define PLATFORM MAC void screen_init(); #endif
// screen.c
#include <string.h> #include <stdlib.h> #include "screen.h" #if PLATFORM == MAC #include <curses.h> void screen_init(){ erase(); } #endif
I don't understand why it is not seeing my prototype in screen.h
Any suggestions/hints are appreciated!
解决方案ISO/IEC 9899:TC2 - 6.2.1.2:
A function prototype is a declaration of a function that declares the types of its parameters.An empty argument list in a function declaration indicates that the number and type of parameters is not known. You must explicitly indicate that the function takes no arguments by using the
void
keyword. Otherwise your function declaration does not count as a valid prototype.void screen_init(void);
这篇关于错误:没有previous原型的功能。为什么会出现这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!