RE: [GD-General] Redundant Include Guards
Brought to you by:
vexxed72
From: Mick W. <mi...@ne...> - 2002-12-16 17:06:33
|
GCC does not need redundant include guards of the form you show below. Header files with internal guards will only be opened once. The only caveat is that you have to use the exact same path, including case, it you do something like: #include "header.h" then later in the same compilation unit. #include "sys\header.h" where they both refer to the same file, then it will get opened twice. This is not typically a big problem, just possibly confusing. Mick. > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...] On > Behalf Of Parveen Kaler > Sent: Sunday, December 15, 2002 6:27 PM > To: gam...@li... > Subject: [GD-General] Redundant Include Guards > > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Sticking with the theme of compile times. > > I'm reading Large-Scale C++ Software Design at the moment. > The author > recommends redundant include guards in .h files: > > // foo.h > #ifndef _INCLUDE_FOO_H_ > #define _INCLUDE_FOO_H_ > > > #ifndef _INCLUDE_BAR_H_ > #include "bar.h" > #endif > > #ifndef _INCLUDE_VECTOR_ > #include <vector> > #define _INCLUDE_VECTOR_ > #endif > > //// > .... > //// > > #endif > > So I tried this for a project of mine that consists of about 10KLOC. > Compiling with gcc3.2 I saw no difference in compile times. > > Are compilers like gcc and msvc smart enough to figure stuff > like this > out? Or is my project just not large enough? The book was > written way > back in 1996, so I'm figuring some of the advice may be a > little out of > date. > > Parveen > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.0.7 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQE9/Tnw6jdpm1dGc/cRAiCsAKCb2DuzooUpjSfzd3iFBDO9RexURgCeKHR6 > uOTV9eicFER6so6dh5PJyJY= > =nVAC > -----END PGP SIGNATURE----- > > > > ------------------------------------------------------- > This sf.net email is sponsored by: > With Great Power, Comes Great Responsibility > Learn to use your power at OSDN's High Performance Computing > Channel http://hpc.devchannel.org/ > _______________________________________________ > Gamedevlists-general mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-general > Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=557 > |