Subject: Re: missing #include ?
To: None <tech-userlevel@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 12/12/2006 05:22:38
> The situation we're talking about is: foo.h needs sys/types.h to work
> properly, and if foo.h should include sys/types.h, or if the
> application pulls it in.  Where is the performance difference?

When there's also bar.h which needs (and putatively includes)
sys/types.h.  The .c-includes paradigm reads sys/types.h only once; the
.h-includes paradigm reads sys/types.h once per file that uses it.

Except that, as has been pointed out multiple times by now, gcc
optimizes this away if sys/types.h is protected with the canonical
ifdef/define/endif bracket.  There still will be a performance hit, but
I fully expect that it will be too small to matter, quite possibly too
small to measure.  (Anyone care enough to bother finding out?)

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B