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 755700 - Do not allow including other headers than the main header
Do not allow including other headers than the main header
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: General
unspecified
Other All
: Normal enhancement
: 4.0
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2015-09-27 16:52 UTC by Sébastien Wilmet
Modified: 2016-11-05 14:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Script used to add the #warning's. (1.79 KB, text/plain)
2016-06-24 20:58 UTC, Sébastien Wilmet
Details

Description Sébastien Wilmet 2015-09-27 16:52:39 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.
Comment 1 Sébastien Wilmet 2015-09-27 16:55:34 UTC
Also, for GtkSourceView 4, maybe the main header can be renamed to <gtksourceview/gtksourceview.h>, which is more logical and easier to remember.
Comment 2 Paolo Borelli 2015-09-27 21:51:37 UTC
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.
Comment 3 Sébastien Wilmet 2015-09-28 16:41:33 UTC
That would be nice, indeed. With some scripts it should be feasible.

See bug #755752.
Comment 4 Sébastien Wilmet 2016-06-24 10:56:37 UTC
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.
Comment 5 Sébastien Wilmet 2016-06-24 20:54:57 UTC
Phase 1 accomplished:
commit 5f5478991938ff2373aaeeb078764a54a9b959f1
Comment 6 Sébastien Wilmet 2016-06-24 20:58:42 UTC
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.
Comment 7 Murray Cumming 2016-06-30 08:59:57 UTC
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]
Comment 8 Sébastien Wilmet 2016-06-30 12:39:16 UTC
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.
Comment 9 Murray Cumming 2016-06-30 13:10:53 UTC
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.)
Comment 10 Murray Cumming 2016-06-30 13:12:10 UTC
GTK+ didn't always require us to use a single includes. They made that change some time.
Comment 11 Sébastien Wilmet 2016-07-01 13:01:51 UTC
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).
Comment 12 Murray Cumming 2016-07-03 20:20:16 UTC
(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.
Comment 13 Sébastien Wilmet 2016-11-05 14:42:34 UTC
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).