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 609280 - glib header #include issues (remove #include "glib.h")
glib header #include issues (remove #include "glib.h")
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-02-08 01:52 UTC by Allison Karlitskaya (desrt)
Modified: 2013-02-03 11:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not include "glib.h" in gio files (2.17 KB, patch)
2010-05-05 17:15 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gasyncqueue (678 bytes, patch)
2010-05-05 17:15 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gtestutils (1.38 KB, patch)
2010-05-05 17:16 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gmem (706 bytes, patch)
2010-05-05 17:16 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review
gthread (1.01 KB, patch)
2010-05-05 17:16 UTC, Javier Jardón (IRC: jjardon)
committed Details | Review

Description Allison Karlitskaya (desrt) 2010-02-08 01:52:03 UTC
the header situation in glib is a little bit random at the moment.

the main problem is that just about everything does #include <glib.h> which means that a single change to a completely-unrelated header file results in the entirety of glib being rebuilt.

i propose that all .c files in glib/ be changed to this:


(for file gfoo.c)

-----
/* Copyright etc...
 *
 */

#include "config.h"                 /* [1] */

#include "gfoo.h"                   /* [2] */

#include <glib/gtestutils.h>        /* [3] */
#include <glib/gslist.h>

#include <stdio.h>                  /* [4] */
#include <string.h>

#include "galias.h"                 /* [5] */

... stuff ...
-----


[1] config.h needs to be in every file and it needs to come first.  See bug 71704.

[2] each .c file should include its corresponding .h before any other includes as a way of 'taking responsibility' for ensuring that the .h file can be #included from any context without errors (ie: the .h file does not require other .h files to come before it).  note that config.h still needs to be first incase the "gfoo.h" includes some system header files.

[3] next, the glib .h files that this module depends on.  it seems to me that this list should be kept as small as possible via transitive reduction (eg: we shouldn't include gmessages.h since that's already included via our include of gtestutils.h).  this increases the chances of changes to .h files breaking things (which will be promptly noticed and fixed) and reduces the chances of .c files silently depending on unnecessary .h files when such changes occur.

<glib.h> should never be included from anything inside of glib/ ever.  test cases should use <glib.h>.  gobject/ and gio/ can use it too.

[4] system headers.  boring.

[5] aliasing stuff.  needs to come after all glib headers, but could maybe be before system headers.


feedback?
Comment 1 Matthias Clasen 2010-02-21 21:09:15 UTC
Sure, sounds ok as a general cleanup goal. 

I tend to sort system headers early (ie between config.h and other glib headers)
Comment 2 Javier Jardón (IRC: jjardon) 2010-05-05 17:15:24 UTC
Created attachment 160357 [details] [review]
Do not include "glib.h" in gio files
Comment 3 Javier Jardón (IRC: jjardon) 2010-05-05 17:15:56 UTC
Created attachment 160358 [details] [review]
gasyncqueue
Comment 4 Javier Jardón (IRC: jjardon) 2010-05-05 17:16:13 UTC
Created attachment 160359 [details] [review]
gtestutils
Comment 5 Javier Jardón (IRC: jjardon) 2010-05-05 17:16:33 UTC
Created attachment 160360 [details] [review]
gmem
Comment 6 Javier Jardón (IRC: jjardon) 2010-05-05 17:16:54 UTC
Created attachment 160361 [details] [review]
gthread
Comment 7 Matthias Clasen 2010-05-06 01:01:13 UTC
Comment on attachment 160357 [details] [review]
Do not include "glib.h" in gio files

looks fine (assuming make check  still works)
Comment 8 Matthias Clasen 2010-05-06 01:01:38 UTC
Comment on attachment 160358 [details] [review]
gasyncqueue

same comment
Comment 9 Matthias Clasen 2010-05-06 01:03:39 UTC
Comment on attachment 160360 [details] [review]
gmem

are you sure we dont need gthreadprivate.h here ?
Comment 10 Javier Jardón (IRC: jjardon) 2010-05-06 15:43:00 UTC
Comment on attachment 160357 [details] [review]
Do not include "glib.h" in gio files

commit 434a4e1d250157b13d7036592f097c18fb8376b1
Comment 11 Javier Jardón (IRC: jjardon) 2010-05-06 15:43:21 UTC
Comment on attachment 160358 [details] [review]
gasyncqueue

commit d1642386c96b4a2a4479cd7c2b5cd8ddadae99e4
Comment 12 Javier Jardón (IRC: jjardon) 2010-05-06 15:43:47 UTC
Comment on attachment 160359 [details] [review]
gtestutils

commit 21302a741cbb3d6373a368df148f6267a0705366
Comment 13 Javier Jardón (IRC: jjardon) 2010-05-06 15:44:27 UTC
Comment on attachment 160360 [details] [review]
gmem

committed after double chekc this

commit c7940d81802194abe1d4497d3daa2f9c59addb5e
Comment 14 Javier Jardón (IRC: jjardon) 2010-05-06 15:45:06 UTC
Comment on attachment 160361 [details] [review]
gthread

comitted the correct patch in commit 81e98c399e11d7621c91ff2911ef4f92c7a382e5
Comment 15 Matthias Clasen 2013-02-03 05:14:03 UTC
I think we're good here
Comment 16 Allison Karlitskaya (desrt) 2013-02-03 11:45:12 UTC
Not really fixed yet for gio/