Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
712 views
in Technique[技术] by (71.8m points)

c - Error: No previous prototype for function. Why am I getting this error?

// 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...