Will this work??

Started by
1 comment, last by clrscr 22 years, 4 months ago
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
-----------------------------When men speak of the future, the Gods laugh.An apology for the devil: it must be remembered that we have heard one side of the case. God has written all the books.Samuel Butler (1835 - 1902)
Advertisement
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