I am making a rogue-like game in C and I am having trouble with file linkage. I am making a custom header file where I declare an array of structures, but when I compile this code:
#ifndef spells
#define spells
struct spells SpellList[55];
#endif // spells
I get an error: Expected identifier or '(' before '[' token.
You are using the identifier spells
for two different purposes: as a "guard macro" for the header file, and as the tag-name for a struct. The compiler does not understand that you want these to be independent. With the code as shown, the preprocessing stage will replace all uses of the identifier spells
with nothing, and then the parsing stage will see
struct SpellList[55];
which is invalid.
You must rename either the guard macro or the struct tag. Since you never need to refer to guard macros anywhere else, it's probably easiest to rename the guard macro.
Incidentally, "rouge" is a type of make-up. The kind of game you are making is a rogue-like.