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

前端 未结 3 1885
耶瑟儿~
耶瑟儿~ 2020-12-09 02:12

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


        
3条回答
  •  一生所求
    2020-12-09 02:17

    I just had this problem today.

    I defined a function that just used internally

    void func(void) {
    }
    
    int main(void) {
        func();
    }
    

    This will give me that warning. I had to add the prototype at the beginning of the file to get rid of the warning.

    void func(void);
    
    void func(void) {
    }
    
    int main(void) {
        func();
    }
    

提交回复
热议问题