Subject: Re: missing #include ?
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 12/10/2006 19:45:01
[re headers including other headers they need]
>> Can we find out what the concensus is?
> IIRC the consensus was: "it needs to be judged on a case by case
> basis".

Well, to the extent that there was a consensus at all. :-)

> The reason is massive namespace pollution that some headers cause,

I've never understood this objection, at least not as an objection to
the sort of fixes I've been arguing for.  If you need (say)
<sys/types.h> in order to make <foo.h> not produce errors, why does it
make any difference from a namespace-pollution point of view whether
this the include of <sys/types.h> happens in the .c file or in foo.h?

> combined with long standing historic practice for certain required
> combinations of includes.

I don't think anyone has been arguing for making traditional
combinations of includes break.  Certainly that's nothing I want.

> New headers should probably be idempotent, and namespace pollution
> should be fixed where possible.

Fixing the namespace pollution is easy.  Tedious and fairly invasive,
but not difficult - except for deciding where to draw the line between
"part of the implementation" and "client of the implementation".

Consider u_long, for example.  Currently, u_long comes from
<sys/types.h>, which also defines a whole wack of other stuff.  To fix
the namespace pollution, all that's needed is

	#include <sys/__types.h>
	typedef __u_long u_long;
	...similar typedefs &c...

	typedef unsigned long __u_long;
	...similar changes to current sys/types.h...

Then in (say) sys/disklabel.h, instead of using uint32_t, include
<sys/__types.h> and use __uint32_t.  You could even go so far as to
have <sys/__uint32_t.h> and the like.

All of these include files should of course have the canonical
#ifndef/#define/.../#endif wrapper (which, as keeps getting pointed out
but people seem to keep forgetting, means that gcc *doesn't* reread the
include file multiple times).

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