Subject: Re: missing #include ?
To: Hubert Feyrer <>
From: Greg Troxel <>
List: tech-userlevel
Date: 12/10/2006 15:38:19
Hubert Feyrer <> writes:

> 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?

The performance issue is that now programs put in the includes that
are needed, and most files are included once.

To make this automatic, the basic scheme would be to put in each .h a
#include of the ones it needs.  Then, including most files would
provoke an include of <sys/types.h>, which would cause it to be read
again and discarded since it's protected with _SYS_TYPES_H_.

These files will likely be in the buffer cache still, and  just
discarded by the preprocessor, so this doesn't seem to bad.  But the
question was (quite reasonably) asked if anyone had actually measured.

Changing to having includes auto-include requirements seems
reasonable.  But it's a large and non-traditional step and it would be
good to examine how other systems do this, especially FreeBSD and