I currently have a few header files. One named "globalVar.h" for global variables, one named "generate.h" for variables having to do with generation, and I have one named "screen.h" for variables having to do with the screen. Whenever I include these and run the file I get an error exactly like this one for each of my variables:
globalVar.h:7:19: warning: 'y' initialized and declared 'extern'
extern int x = 1, y = 1; // player coordinates
Why is this happening? For this example, here's the code for the "globalVar.h" header:
#ifndef GLOBALVAR_H
#define GLOBALVAR_H
#include <iostream>
#include <windows.h>
extern int x = 1, y = 1; // player coordinates
extern int health = 100; // player health
extern int player = '@'; // player symbol
extern int gX, gY; // goblin coordinates
extern int health = 100; // goblin health
extern int goblin = 'G'; // goblin symbol
#endif
Am I doing something wrong? Surely I am because this makes sense to me, but I don't really know how header files work.
Anyone have any ideas?