DragonFly kernel List (threaded) for 2007-06
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: #ifndef's before including the headers (redundant inclusion test?)
:Hi.
:
:Why is the following test necessary before including headers? (for
:example in sys/netgraph/netgraph.h).
:
:#ifndef _SYS_QUEUE_H_
:#include <sys/queue.h>
:#endif
:
:when <sys/queue.h> already tests for inclusion?
:
:#ifndef _SYS_QUEUE_H_
:#define _SYS_QUEUE_H_
:...
:#endif
:
:Thanks,
:Nuno
It isn't necessarily, it just prevents GCC from re-scanning header
files that it has already processed. It just speeds up compilation
a bit.
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.
-Matt
Matthew Dillon
<dillon@backplane.com>
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]