GNOME Bugzilla – Bug 755700
Do not allow including other headers than the main header
Last modified: 2016-11-05 14:42:34 UTC
Write it so we don't forget about it. This should be done for GtkSourceView 4, since it's an API break. In early 3.x versions, the gtk-doc documentation still referred to other headers, so I guess it is still used in lots of applications.
Also, for GtkSourceView 4, maybe the main header can be renamed to <gtksourceview/gtksourceview.h>, which is more logical and easier to remember.
For GtkSourceView 4 I really want to move to the "Gsv" namespace, that would clear up many confusions and stop stomping on the gtk namespace. This would also allow to have "gsv.h" as the sinngle include header without conflicting with the header for the view widget which would be gsvview.h or gsvtextview.h depending on what we decide to call it.
That would be nice, indeed. With some scripts it should be feasible. See bug #755752.
Actually in GtkSourceView 3 we can use #warning in case another public header is included. And for GtkSourceView 4 we would just need to change the #warning into #error.
Phase 1 accomplished: commit 5f5478991938ff2373aaeeb078764a54a9b959f1
Created attachment 330341 [details] Script used to add the #warning's. Here the script used to add the #warning's. With a simple for loop in shell: #!/bin/sh for i in $(cat list); do ./script /home/seb/gnome/gtksourceview/gtksourceview/$i done ------------- And the list of headers taken from gtksource.h.
This use of the non-standard GCC "warning" itself causes compiler warnings, which stops us from using warnings-as-errors with lots of warnings turned on. We don't have this problem with GTK+. For instance: /opt/gnome/include/gtksourceview- 3.0/gtksourceview/gtksourcebuffer.h:31:6: error: #warning is a GCC extension [-Werror]
GTK+ uses #error, not #warning. But an #error would be an API break for GtkSourceView 3. Building gtksourceviewmm 3.18.0 with GtkSourceView master, in jhbuild, works fine for me. I don't have the "#warning is a GCC extension" warning/error.
Try building after doing: ./autogen.sh --prefix=/whatever --enable-warnings=fatal We turn on all the warnings we can, and as errors, when that is on, for instance during distcheck. We don't turn that on during normal builds. (We've been doing that for years.)
GTK+ didn't always require us to use a single includes. They made that change some time.
I can reproduce the error with --enable-warnings=fatal with gtksourceviewmm 3.18.0. But I see that it's fixed in gtksourceviewmm 3.21.2. GLib also uses #warning, for example at: https://git.gnome.org/browse/glib/tree/gio/gcredentials.c?h=2.48.0#n96 The #warning is present only if __GNUC__ is defined. In GTK+, the #error's in the secondary headers have been added for GTK+ 3.0. So an API break was possible. Here for GtkSourceView, the #warning's are just to prepare the ground for GSV 4, so that projects relying on GSV will have less things to do (and there will also be less things to do in GSV itself).
(In reply to Sébastien Wilmet from comment #11) > But I see that it's fixed in gtksourceviewmm 3.21.2. Indeed. Including the single header does seem to avoid the warning about #warning. So it doesn't really seem to be a problem. Thanks for taking the time.
The #warning's have been changed to #error's with commit b84a09e33f754c2f46090c3cbaedef794df4bce7 (GtkSourceView 3.24 has branched and is the latest GtkSourceView 3 version, the master branch is now open for GtkSourceView 4).