Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

clrscr

Will this work??

This topic is 6195 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!