warning in extern declaration

后端 未结 4 809
情歌与酒
情歌与酒 2020-11-29 12:12
#include
#include
#define GREY 1
#define BLACK 0
#define WHITE 2
typedef struct node * graph;
typedef struct stack * snode;

graph cno         


        
4条回答
  •  难免孤独
    2020-11-29 12:30

    I just had this warning with gcc and it's a simple fix. stack_counter should not be initialised in the header, but rather in a source file that includes it. So the header should just use:

    extern int stack_counter;
    

    Then declare and initialise stack_counter in global scope of just one source file that includes that header:

    int stack_counter = 0;
    

提交回复
热议问题