Subject: Re: bug#21707: include-file cleanup for src directory

From: Paul Eggert <[email-masked]>
Date: Tue, 20 Oct 2015 13:52:42 -0700

On 10/20/2015 12:15 PM, Eli Zaretskii wrote:
> Even standard C headers sometimes require order, for example, 
> sys/types.h should be included before sys/stat.h.

Oh my goodness your memory goes a long way back!  But the C Standard 
never required a particular header order (it never standardized 
sys/types.h or sys/stat.h). POSIX did originally require that one must 
include both <sys/types.h> and <sys/stat.h> before using functions like 
'stat', but that requirement was removed a while ago; e.g., nowadays 
only <sys/stat.h> must be included before using 'stat'.  And it's not 
hard to see why the old POSIX requirement was removed: a .h file should 
describe an API standalone, to avoid unnecessarily constraining the 
API's users.

> I thought we could perhaps come up with a method that would allow 
> anyone easily see which headers are needed on every supported platform

I started something along those lines, but it's harder than it looks. 
The current patch came from my woefully-inadequate approximation to the 
tools I wanted.

> I think the real problem is to keep this state once we get there.

Yes. Part of the job would be to write better checking tools. And part, 
I expect, would be to simplify Emacs's complicated uses of headers. For 
example, although we sometimes have headers A and B that use each 
others' symbols, it wouldn't be cool to have both A #include B and B 
#include A. Some of this simplification will likely be needed anyway, as 
we change more macros to inline functions.