I have been making a Roguelike recently, and have been getting compile errors with this specific code:
typedef const char* string;
typedef struct {
string name;
string desc;
int dice;
int sides;
} weapon;
typedef struct {
string name;
string desc;
int dice;
int sides;
} armor;
typedef struct {
string name;
char icon;
int x;
int y;
weapon wep;
armor arm;
int hp;
int maxhp;
} creature;
This is in a header file.
Another file defines external variables:
extern creature monsters[MAX_MONSTERS];
extern creature level_cre[MAX_LEVELCRE];
extern weapon weapons[MAX_WEAPONS];
extern armor armors[MAX_ARMORS];
In the file that defines weapon and armor arrays:
weapon weapons[MAX_WEAPONS] = {
{"Sword", "A steel sword", 1, 6},
};
armor armors[MAX_ARMORS] = {
{"Leather", "Leather armor", 1, 10},
};
And the part that is giving me an error:
creature monsters[MAX_MONSTERS] = {
{"Skeleton", 's', 0, 0, weapons[0], armors[0], 100, 100},
{"Orc", 'o', 0, 0, weapons[0], armors[0], 100, 100},
};
Running this gives me the error in the title, and after doing some research it appears to come from not defining constants properly. I am at a complete loss here as to what to do. Any help would be appreciated. :)