[Cogl] [PATCH] Make cogl-sdl.h a top-level header
Robert Bragg
robert at sixbynine.org
Thu Nov 28 09:42:31 PST 2013
From: Robert Bragg <robert at linux.intel.com>
This makes it so that cogl-sdl.h is a top-level header no longer
automatically included by cogl.h. This avoids lots of warnings building
the conformance tests and examples due to SDL.h warning when
__STRICT_ANSI__ isn't defined.
---
cogl/cogl-sdl.h | 34 ++++++++++++++++++++++++++++++----
cogl/cogl.h | 3 ---
examples/cogl-sdl-hello.c | 1 +
examples/cogl-sdl2-hello.c | 1 +
4 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/cogl/cogl-sdl.h b/cogl/cogl-sdl.h
index 486732e..2c3d603 100644
--- a/cogl/cogl-sdl.h
+++ b/cogl/cogl-sdl.h
@@ -21,13 +21,26 @@
*
*/
-#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
-#error "Only <cogl/cogl.h> can be included directly."
-#endif
-
#ifndef __COGL_SDL_H__
#define __COGL_SDL_H__
+/* NB: this is a top-level header that can be included directly but we
+ * want to be careful not to define __COGL_H_INSIDE__ when this is
+ * included internally while building Cogl itself since
+ * __COGL_H_INSIDE__ is used in headers to guard public vs private api
+ * definitions
+ */
+#ifndef COGL_COMPILATION
+
+/* Note: When building Cogl .gir we explicitly define
+ * __COGL_H_INSIDE__ */
+#ifndef __COGL_H_INSIDE__
+#define __COGL_H_INSIDE__
+#define __COGL_SDL_H_MUST_UNDEF_COGL_H_INSIDE__
+#endif
+
+#endif /* COGL_COMPILATION */
+
#include <cogl/cogl-context.h>
#include <cogl/cogl-onscreen.h>
#include <SDL.h>
@@ -221,4 +234,17 @@ cogl_sdl_onscreen_get_window (CoglOnscreen *onscreen);
COGL_END_DECLS
+/* The gobject introspection scanner seems to parse public headers in
+ * isolation which means we need to be extra careful about how we
+ * define and undefine __COGL_H_INSIDE__ used to detect when internal
+ * headers are incorrectly included by developers. In the gobject
+ * introspection case we have to manually define __COGL_H_INSIDE__ as
+ * a commandline argument for the scanner which means we must be
+ * careful not to undefine it in a header...
+ */
+#ifdef __COGL_SDL_H_MUST_UNDEF_COGL_H_INSIDE__
+#undef __COGL_H_INSIDE__
+#undef __COGL_SDL_H_MUST_UNDEF_COGL_H_INSIDE__
+#endif
+
#endif /* __COGL_SDL_H__ */
diff --git a/cogl/cogl.h b/cogl/cogl.h
index fdb68bf..5809bf1 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -100,9 +100,6 @@
/* XXX: This will definitly go away once all the Clutter winsys
* code has been migrated down into Cogl! */
#include <cogl/cogl-clutter.h>
-#ifdef COGL_HAS_SDL_SUPPORT
-#include <cogl/cogl-sdl.h>
-#endif
/* The gobject introspection scanner seems to parse public headers in
* isolation which means we need to be extra careful about how we
diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c
index 3d656e3..157c3e8 100644
--- a/examples/cogl-sdl-hello.c
+++ b/examples/cogl-sdl-hello.c
@@ -1,4 +1,5 @@
#include <cogl/cogl.h>
+#include <cogl/cogl-sdl.h>
#include <stdio.h>
#include <SDL.h>
diff --git a/examples/cogl-sdl2-hello.c b/examples/cogl-sdl2-hello.c
index f84c40e..0e32fdb 100644
--- a/examples/cogl-sdl2-hello.c
+++ b/examples/cogl-sdl2-hello.c
@@ -1,4 +1,5 @@
#include <cogl/cogl.h>
+#include <cogl/cogl-sdl.h>
#include <stdio.h>
#include <SDL.h>
--
1.8.3.1
More information about the Cogl
mailing list