Skip to content

Commit 844df2b

Browse files
committed
libgimp*: add guards that #error out if individual files are included
This only helps to maintain proper includes in app/ and shouldn't affect plug-ins at all, because these are supposed to only include the main headers from libgimp/ since the beginning of time. The gimpfootypes.h files do not have these guards, so we can continue to maintain app/'s include policy that is very likely to error out if wrong things are included.
1 parent ee03177 commit 844df2b

File tree

104 files changed

+408
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+408
-20
lines changed

configure.ac

+4
Original file line numberDiff line numberDiff line change
@@ -2005,6 +2005,10 @@ AC_CONFIG_COMMANDS([libgimpbase/gimpversion.h], [
20052005
* This is a generated file. Please modify 'configure.ac'
20062006
*/
20072007
2008+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
2009+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
2010+
#endif
2011+
20082012
#ifndef __GIMP_VERSION_H__
20092013
#define __GIMP_VERSION_H__
20102014

libgimpbase/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ AM_CPPFLAGS = \
5151
-DGIMP_DATA_VERSION=\"$(GIMP_DATA_VERSION)\" \
5252
-DGIMP_SYSCONF_VERSION=\"$(GIMP_SYSCONF_VERSION)\" \
5353
-DGIMP_PLUGIN_VERSION=\"$(GIMP_PLUGIN_VERSION)\" \
54-
-DG_LOG_DOMAIN=\"LibGimpBase\"
54+
-DG_LOG_DOMAIN=\"LibGimpBase\" \
55+
-DGIMP_BASE_COMPILATION
5556

5657
AM_CCASFLAGS = \
5758
-I$(top_builddir) \

libgimpbase/gimpbase.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef __GIMP_BASE_H__
2020
#define __GIMP_BASE_H__
2121

22+
#define __GIMP_BASE_H_INSIDE__
2223

2324
#include <libgimpbase/gimpbasetypes.h>
2425

@@ -38,5 +39,6 @@
3839
#include <libgimpbase/gimpsignal.h>
3940
#endif
4041

42+
#undef __GIMP_BASE_H_INSIDE__
4143

4244
#endif /* __GIMP_BASE_H__ */

libgimpbase/gimpchecks.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
20+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_CHECKS_H__
2024
#define __GIMP_CHECKS_H__
2125

libgimpbase/gimpcpuaccel.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
20+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_CPU_ACCEL_H__
2024
#define __GIMP_CPU_ACCEL_H__
2125

libgimpbase/gimpdatafiles.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
23+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_DATAFILES_H__
2327
#define __GIMP_DATAFILES_H__
2428

libgimpbase/gimpenv.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
23+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMPENV_H__
2327
#define __GIMPENV_H__
2428

libgimpbase/gimplimits.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
23+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_LIMITS_H__
2327
#define __GIMP_LIMITS_H__
2428

libgimpbase/gimpmemsize.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
20+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_MEMSIZE_H__
2024
#define __GIMP_MEMSIZE_H__
2125

libgimpbase/gimpparasite.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
23+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_PARASITE_H__
2327
#define __GIMP_PARASITE_H__
2428

libgimpbase/gimprectangle.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
20+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_RECTANGLE_H__
2024
#define __GIMP_RECTANGLE_H__
2125

libgimpbase/gimpunit.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
23+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_UNIT_H__
2327
#define __GIMP_UNIT_H__
2428

libgimpbase/gimputils.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_BASE_H_INSIDE__) && !defined (GIMP_BASE_COMPILATION)
20+
#error "Only <libgimpbase/gimpbase.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_UTILS_H__
2024
#define __GIMP_UTILS_H__
2125

libgimpcolor/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ endif
4747
libgimpcolorincludedir = $(includedir)/gimp-$(GIMP_API_VERSION)/libgimpcolor
4848

4949
AM_CPPFLAGS = \
50-
-DG_LOG_DOMAIN=\"LibGimpColor\"
50+
-DG_LOG_DOMAIN=\"LibGimpColor\" \
51+
-DGIMP_COLOR_COMPILATION
5152

5253
INCLUDES = \
5354
-I$(top_srcdir) \

libgimpcolor/gimpadaptivesupersample.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_ADAPTIVE_SUPERSAMPLE_H__
2024
#define __GIMP_ADAPTIVE_SUPERSAMPLE_H__
2125

libgimpcolor/gimpbilinear.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_BILINEAR_H__
2024
#define __GIMP_BILINEAR_H__
2125

libgimpcolor/gimpcmyk.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_CMYK_H__
2024
#define __GIMP_CMYK_H__
2125

libgimpcolor/gimpcolor.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef __GIMP_COLOR_H__
2020
#define __GIMP_COLOR_H__
2121

22+
#define __GIMP_COLOR_H_INSIDE__
2223

2324
#include <libgimpcolor/gimpcolortypes.h>
2425

@@ -31,5 +32,6 @@
3132
#include <libgimpcolor/gimphsv.h>
3233
#include <libgimpcolor/gimprgb.h>
3334

35+
#undef __GIMP_COLOR_H_INSIDE__
3436

3537
#endif /* __GIMP_COLOR_H__ */

libgimpcolor/gimpcolormanaged.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
23+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_COLOR_MANAGED_H__
2327
#define __GIMP_COLOR_MANAGED_H__
2428

libgimpcolor/gimpcolorspace.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_COLOR_SPACE_H__
2024
#define __GIMP_COLOR_SPACE_H__
2125

libgimpcolor/gimphsl.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_HSL_H__
2024
#define __GIMP_HSL_H__
2125

libgimpcolor/gimphsv.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_HSV_H__
2024
#define __GIMP_HSV_H__
2125

libgimpcolor/gimprgb.h

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
* <http://www.gnu.org/licenses/>.
1717
*/
1818

19+
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
20+
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
21+
#endif
22+
1923
#ifndef __GIMP_RGB_H__
2024
#define __GIMP_RGB_H__
2125

libgimpconfig/Makefile.am

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ endif
4444
libgimpconfigincludedir = $(includedir)/gimp-$(GIMP_API_VERSION)/libgimpconfig
4545

4646
AM_CPPFLAGS = \
47-
-DG_LOG_DOMAIN=\"LibGimpConfig\"
47+
-DG_LOG_DOMAIN=\"LibGimpConfig\" \
48+
-DGIMP_CONFIG_COMPILATION
4849

4950
INCLUDES = \
5051
-I$(top_srcdir) \
@@ -132,7 +133,7 @@ CLEANFILES = $(gen_sources)
132133

133134
$(srcdir)/gimpcolorconfig-enums.c: $(srcdir)/gimpcolorconfig-enums.h $(GIMP_MKENUMS)
134135
$(GIMP_MKENUMS) \
135-
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#include \"libgimpbase/gimpbasetypes.h\"\n#include \"gimpcolorconfig-enums.h\"\n#include \"libgimp/libgimp-intl.h\"" \
136+
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#include \"libgimpbase/gimpbase.h\"\n#include \"gimpcolorconfig-enums.h\"\n#include \"libgimp/libgimp-intl.h\"" \
136137
--fprod "\n/* enumerations from \"@filename@\" */" \
137138
--vhead "GType\n@enum_name@_get_type (void)\n{\n static const G@Type@Value values[] =\n {" \
138139
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \

libgimpconfig/gimpcolorconfig-enums.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "config.h"
55
#include <glib-object.h>
6-
#include "libgimpbase/gimpbasetypes.h"
6+
#include "libgimpbase/gimpbase.h"
77
#include "gimpcolorconfig-enums.h"
88
#include "libgimp/libgimp-intl.h"
99

libgimpconfig/gimpcolorconfig.c

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <glib-object.h>
2525

26+
#include "libgimpbase/gimpbase.h"
2627
#include "libgimpcolor/gimpcolor.h"
2728

2829
#include "gimpconfigtypes.h"

libgimpconfig/gimpcolorconfig.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_COLOR_CONFIG_H__
2327
#define __GIMP_COLOR_CONFIG_H__
2428

libgimpconfig/gimpconfig-deserialize.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_DESERIALIZE_H__
2327
#define __GIMP_CONFIG_DESERIALIZE_H__
2428

libgimpconfig/gimpconfig-error.h

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
* <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
22+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
23+
#endif
24+
2125
#ifndef __GIMP_CONFIG_ERROR_H__
2226
#define __GIMP_CONFIG_ERROR_H__
2327

libgimpconfig/gimpconfig-iface.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_IFACE_H__
2327
#define __GIMP_CONFIG_IFACE_H__
2428

libgimpconfig/gimpconfig-params.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_PARAMS_H__
2327
#define __GIMP_CONFIG_PARAMS_H__
2428

libgimpconfig/gimpconfig-path.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_PATH_H__
2327
#define __GIMP_CONFIG_PATH_H__
2428

25-
2629
G_BEGIN_DECLS
2730

2831
/* For information look into the C source or the html documentation */

libgimpconfig/gimpconfig-serialize.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_SERIALIZE_H__
2327
#define __GIMP_CONFIG_SERIALIZE_H__
2428

libgimpconfig/gimpconfig-utils.h

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
* <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
#if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
23+
#error "Only <libgimpconfig/gimpconfig.h> can be included directly."
24+
#endif
25+
2226
#ifndef __GIMP_CONFIG_UTILS_H__
2327
#define __GIMP_CONFIG_UTILS_H__
2428

0 commit comments

Comments
 (0)