GNOME Bugzilla – Bug 71704
Header file include order
Last modified: 2013-01-01 18:56:50 UTC
Lots of glib files fail to include <config.h> early enough. This messes up Solaris support because _FILE_OFFSET_BITS ends up being defined too late, i.e., after system headers which define it (as 32) have been included. Therefore I see lots of In file included from gconvert.c:30: ../config.h:402: warning: `_FILE_OFFSET_BITS' redefined /usr/include/sys/feature_tests.h:96: warning: this is the location of the previous definition Solution: include <config.h> first thing all over the place. (That has been known to solve other problems too. I think Nautilus has a program that can check this.)
Created attachment 6746 [details] [review] Minimal patch to fix observed problems
Any particular reason why this patch adds config.h to files where it wasn't previously?
To silence warnings, :-) These files must be including config.h indirectly, i.e., via some other .h file.
Sun Feb 17 11:37:06 2002 Owen Taylor <otaylor@redhat.com> * glib/glibintl.h: Error out of config.h wasn't included rather than including it, since config.h must be the first thing included. * glib/gconvert.c glib/gmarkup.c glib/gshell.c glib/gspawn.c glib/gunibreak.c glib/gunidecomp.c glib/guniprop.c: Include config.h as the first thing. (#71704, Morten Welinder)
Actually config.h should always be included, should always be first, and should be in parentheses. Also system headers should be included early, but after config.h of course. Here's a patch for glib that does this. I can provide a similar patch for gobject etc. if you want me to.
Created attachment 6757 [details] [review] patch that adds config.h all over the place and attempts to unify include order
If you add comments to a bug after it has been resolved, you _must_ reopen the bug or your comments will very likely get lost. Putting on the 2.0.1 milestone as a non-urgent code cleanup.
gmodule/glib-genmarshal.c needs to include config.h earlier.
I've committed the following: Tue May 7 15:03:02 2002 Owen Taylor <otaylor@redhat.com> * glib-genmarshal.c: Fix include order for config.h (#71704, Morten Welinder) in stable and head. I'd like to see Sven's patch in head, but also extended to cover gobject/ and gmodule/.
Sven, do you still plan to provide an extended patch ?
I'll do if I feel very very bored one day but taking into account that the time horizon is full of milestones I don't see that day coming soon.
Tue Dec 3 20:22:27 2002 Owen Taylor <otaylor@redhat.com> * glib/*.c: Patch from Sven Neumann to make the include order consistent. (#71704) Leaving open do do the same fixes in gobject/, gmodule/
Created attachment 96107 [details] [review] Same as previous patches, but this one is for gobject/ dir
Created attachment 96108 [details] [review] Same as before, but for gmodule/ dir That's it. Hope they are useful.
Committed the gmodule patch, thanks. Moving to gobject for the gobject patch. 2007-11-07 Matthias Clasen <mclasen@redhat.com> * *.c: Make header include order consistent (#71704, Diego Escalante Urrelo)
In gmodule/gmodule.c, if 'G_OS_WIN32' is defined, 'io.h' is included. But '#include <io.h>' is before the definition of 'G_OS_WIN32'. So it's never included. '#include <io.h>' should be moved after '#include "gmodule.h"'.
Created attachment 203804 [details] [review] Include system headers early This was fixed for gobject in http://git.gnome.org/browse/glib/commit/?id=5602b7e275ef5fb76cf7847f35b120dce3111705 While I was looking at that I spotted a regression in gobject/gatomicarray.c. I'll attach a patch for that. I only checked gobject so there could possibly be regressions in other places as well. The problem in gmodule/gmodule.c mentioned in #16 was also already fixed.