[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reasons for having no inclusion guards in config.h

From: Ralf Wildenhues
Subject: Re: reasons for having no inclusion guards in config.h
Date: Mon, 8 Mar 2010 06:34:51 +0100
User-agent: Mutt/1.5.20 (2009-10-28)

* Bob Friesenhahn wrote on Mon, Mar 08, 2010 at 02:12:56AM CET:
> The conditional inclusion of content is only an optimization.


> The
> content of the typical config.h is quite easy to parse.  Opening the
> file to inspect it is surely much more overhead than whatever
> parsing overhead is saved by the extra conditional.

Modern compilers like GCC won't ever open a header twice if that is safe
to do so; that is, it has an inclusion guard around all of its
non-comment contents, and no related defines changed since the last

Of course parsing of config.h is probably still negligible compared to
most optimization passes, or even just parsing any nontrivial C++

One much better reason not to guard config.h is that, by documentation,
multiple inclusion of it is erroneous, and inclusion of several config.h
files, possibly from different locations, is dangerous practice, and I
want the preprocessor to help me and complain about this if it can.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]