Jump to content
  • Advertisement

Archived

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

dave

Testing For A Class Name:..

This topic is 5215 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

What i would like to do is create one Header file that i can include in all other .CPP files. Supposing that i want one of the CPP files to use only say half of the includes within this header, is it possible to test against the name of the class that the header is being called from using the pre-proceesor? Therefore excluding these headers from the build for that CPP. regards, ACE

Share this post


Link to post
Share on other sites
Advertisement
.H
#ifndef DONTINCLUDE
class ..
#endif
.CPP
#define DONTINCLUDE // so this CPP won't include

..
#undef DONTINCLUDE // so other CPPs can include


--
You're Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..

[edited by - Pipo DeClown on May 9, 2004 9:01:11 AM]

[edited by - Pipo DeClown on May 9, 2004 9:01:35 AM]

Share this post


Link to post
Share on other sites
Including one global header file in each file is a lazy person''s way out of manually putting the header files you need. It can lead to circular dependencies and other such nasties. In short, don''t be so lazy and just include the headers you need. You''re lucky I''m even posting this, because I usually let people find out for themselves how bad it is.

Share this post


Link to post
Share on other sites
Pipo DeClown - CPP files (translation units) are all compiled separately. Macros defined in one translation unit have absolutely no effect whatsoever on other translation units.

ace_lovegrove - Use macro guards and pass the -DMYMACRO (or /DMYMACRO) option to the compiler:

Header:

#if defined(USE_FOO_VERSION_1)
class Foo {};
#elif defined(USE_FOO_VERSION_2)
class Foo {};
#else
#error You must define USE_FOO_VERSION_1 or USE_FOO_VERSION_1
#endif


Command line: g++ -c -DUSE_FOO_VERSION_1 main.c or the equivalent for your compiler - see the docs.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!