Will this work??
Lets say I have this in a file "gamestuff.h"
#ifdef TROOPS
struct Troops
{
//Troops Stuff
};
#endif
#ifdef NAVY
struct Navy
{
//Navy Stuff
};
endif
Ok now lets say I do this in Troops.c
#define TROOPS
#include "gamestuff.h"
//Troop Stuff here
Only the troop struct will be declared right? If thats not the case, does this even do anything?
"A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila."
-Mitch Ratliffe
I''m not sure what would happen. In my opinion, it would be easier just to create separate files for each (i.e. Troops.h and Navy.h).
It will work fine because #ifdef is understood as a pre-processing directive, so considering you define TROOPS and include your header file, these 2 lines (#define & #include)will be replaced by the pre-processor in text-mode by the declaration of your structure.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement