GNOME Bugzilla – Bug 640449
Include config.h only when needed
Last modified: 2020-11-24 09:57:27 UTC
Created attachment 179200 [details] [review] Patch I saw that config.h is included in a lot of files, but sometimes it is not needed. To be sure that it's not needed, here is what I did: grep -e "^#undef" config.h.in | cut -d " " -f 2 > config.list ./verif_config_removed.sh config.list gedit/file.c With verif_config_removed.sh: #!/usr/bin/env bash cat $1 | xargs -i grep -n --color {} $2 So I took config.h.in to generate a list of symbols and then grep for each symbol in a particular file. The patch cleans only a few files, I'll do the others as I advance with the libgedit.
mmmm, feel free to provide an updated patch, anyway it is not much of a problem.
So is this bug a WONTFIX and the patch rejected?
yes, we usually keep config.h in all the files for consistency
I reopen this bug, I think it's quite useful to know that a file doesn't depend on config.h to make this file reusable (for the libgedit project for example).
Including config.h is actually required for any file that uses any of glib's many logging functions due to G_LOG_DOMAIN, including: - g_return_*if_*() - g_warn_*if_*() - g_debug() - g_info() - g_warning() - g_critical() - g_message() - g_error() Which means pretty much every file will need this and makes it simply easier to avoid mistakes which it isn't included.
Ok, now I better understand why it's almost always included.
I come back again on this bug. G_LOG_DOMAIN isn't defined in gedit's config.h. For an application it is generally not defined, as the doc of G_LOG_DOMAIN explains. For a library (at least GTK+ and GtkSourceView), it is neither defined in config.h, since G_LOG_DOMAIN is passed in the CPPFLAGS. So I think it is safe to remove the useless config.h includes.
I'd like to work on this bug. I am a beginner.
Mass-closing of all gedit bugzilla tickets. Special "code" to find again all those gedit bugzilla tickets that were open before the mass-closing: 2bfe1b0590a78457e1f1a6a90fb975f5878cb60064ccfe1d7db76ca0da52f0f3 By searching the above sha256sum in bugzilla, the gedit contributors can find again the tickets. We may be interested to do so when we work on a specific area of the code, to at least know the known problems and possible enhancements. We do this mass-closing because bugzilla.gnome.org is being replaced by gitlab.gnome.org.