After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 71704 - Header file include order
Header file include order
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
1.3.x
Other opensolaris
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-02-16 21:19 UTC by Morten Welinder
Modified: 2013-01-01 18:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal patch to fix observed problems (3.62 KB, patch)
2002-02-16 21:49 UTC, Morten Welinder
committed Details | Review
patch that adds config.h all over the place and attempts to unify include order (20.80 KB, patch)
2002-02-18 00:10 UTC, Sven Neumann
committed Details | Review
Same as previous patches, but this one is for gobject/ dir (11.58 KB, patch)
2007-09-24 09:53 UTC, Diego Escalante Urrelo (not reading bugmail)
none Details | Review
Same as before, but for gmodule/ dir (2.70 KB, patch)
2007-09-24 09:56 UTC, Diego Escalante Urrelo (not reading bugmail)
committed Details | Review
Include system headers early (816 bytes, patch)
2011-12-18 18:37 UTC, Thomas Andersen
none Details | Review

Description Morten Welinder 2002-02-16 21:19:46 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.)
Comment 1 Morten Welinder 2002-02-16 21:49:03 UTC
Created attachment 6746 [details] [review]
Minimal patch to fix observed problems
Comment 2 Owen Taylor 2002-02-17 00:28:58 UTC
Any particular reason why this patch adds config.h to files
where it wasn't previously?
Comment 3 Morten Welinder 2002-02-17 14:04:47 UTC
To silence warnings, :-)  These files must be including config.h
indirectly, i.e., via some other .h file.
Comment 4 Owen Taylor 2002-02-17 23:14:41 UTC
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)
Comment 5 Sven Neumann 2002-02-18 00:08:40 UTC
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.
Comment 6 Sven Neumann 2002-02-18 00:10:43 UTC
Created attachment 6757 [details] [review]
patch that adds config.h all over the place and attempts to unify include order
Comment 7 Owen Taylor 2002-02-18 15:13:23 UTC
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.
Comment 8 Morten Welinder 2002-03-01 22:09:12 UTC
gmodule/glib-genmarshal.c needs to include config.h earlier.
Comment 9 Owen Taylor 2002-05-07 19:07:57 UTC
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/.
Comment 10 Matthias Clasen 2002-11-06 00:09:15 UTC
Sven, do you still plan to provide an extended patch ?
Comment 11 Sven Neumann 2002-11-06 01:59:40 UTC
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.
Comment 12 Owen Taylor 2002-12-04 01:30:34 UTC
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/
Comment 13 Diego Escalante Urrelo (not reading bugmail) 2007-09-24 09:53:34 UTC
Created attachment 96107 [details] [review]
Same as previous patches, but this one is for gobject/ dir
Comment 14 Diego Escalante Urrelo (not reading bugmail) 2007-09-24 09:56:30 UTC
Created attachment 96108 [details] [review]
Same as before, but for gmodule/ dir

That's it. Hope they are useful.
Comment 15 Matthias Clasen 2007-11-08 03:48:24 UTC
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)
Comment 16 Kazuki Iwamoto 2007-11-08 18:35:06 UTC
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"'.
Comment 17 Thomas Andersen 2011-12-18 18:37:18 UTC
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.