#ifndef's before including the headers (redundant inclusion test?)
dillon at apollo.backplane.com
Sun Jun 3 13:49:48 PDT 2007
:Why is the following test necessary before including headers? (for
:example in sys/netgraph/netgraph.h).
:when <sys/queue.h> already tests for inclusion?
It isn't necessarily, it just prevents GCC from re-scanning header
files that it has already processed. It just speeds up compilation
GCC does have an option to do that sort of thing automatically but
I really disagree with 'features' like that which break the C
language and allow really sloppy programming.
In anycase, for compilation performance one doesn't have to do it
with every #include (for example, I almost never bother in .C files),
but doing it in some of the more recursive header files greatly
reduces the load on the preprocessor.
<dillon at backplane.com>
More information about the Kernel