[PATCH] Always include defs.h first.

Joel Brobecker brobecker@adacore.com
Thu Nov 8 05:04:00 GMT 2012


> What is the include order of "defs.h" and system headers, such as
> <ctype.h> and <stdio.h>?  When I learnt C programming some years
> ago, it was said system headers are included first, and then your
> own headers. This rule doesn't apply here?

My understanding is that "defs.h" should always be included first.
It sets things up nicely for the rest of the includes (such as
including the various config.h files, which can have an effect on
how other system includes are expanded). Eg:

    /* Enable extensions on AIX 3, Interix.  */
    #ifndef _ALL_SOURCE
    # undef _ALL_SOURCE
    #endif

For the rest, I don't really know if there is a recommended order,
or not. I don't think we're completely consistent on that. I think
I've seen code that intermingles both.

-- 
Joel



More information about the Gdb-patches mailing list