summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-09-19 10:31:18 +0300
committerM Joonas Pihlaja <jpihlaja@cc.helsinki.fi>2009-09-19 10:40:43 +0300
commit79613500f185893bb2d5acb99143e97ece2ebb87 (patch)
tree6d4dd3ed7b3cefd90b1027e05a39abada07748ae
parent4987324ec141f8959bb314a1f2b4173438f4842d (diff)
Make it compile with g++.HEADmaster
-rw-r--r--cairosdl.c21
-rw-r--r--cairosdl.h7
2 files changed, 23 insertions, 5 deletions
diff --git a/cairosdl.c b/cairosdl.c
index eb9af6e..fcfa8fa 100644
--- a/cairosdl.c
+++ b/cairosdl.c
@@ -28,2 +28,6 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* forward references */
@@ -52,4 +56,5 @@ _cairosdl_blit_and_premultiply (
/* We're hanging the SDL_Surface as a user datum on the
- * cairo_surface_t representing it using this key. */
-static cairo_user_data_key_t const CAIROSDL_TARGET_KEY[1];
+ * cairo_surface_t representing it using this key. Turns out we need
+ * to initialise it for C++. */
+static cairo_user_data_key_t const CAIROSDL_TARGET_KEY[1] = {{1}};
@@ -106,3 +111,4 @@ cairosdl_surface_create (
* platforms so we'll just go ahead anyway. */
- target = cairo_image_surface_create_for_data (sdl_surface->pixels,
+ unsigned char *data = (unsigned char*)(sdl_surface->pixels);
+ target = cairo_image_surface_create_for_data (data,
format,
@@ -145,3 +151,4 @@ cairosdl_surface_get_target (
{
- return cairo_surface_get_user_data (surface, CAIROSDL_TARGET_KEY);
+ void *udata = cairo_surface_get_user_data (surface, CAIROSDL_TARGET_KEY);
+ return (SDL_Surface*)(udata);
}
@@ -161,3 +168,3 @@ _cairosdl_surface_obtain_SDL_buffer(
if (OUT_buffer)
- *OUT_buffer = sdl_surface->pixels;
+ *OUT_buffer = (unsigned char *)(sdl_surface->pixels);
if (OUT_stride)
@@ -689 +696,5 @@ _cairosdl_blit_and_premultiply (
}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cairosdl.h b/cairosdl.h
index beb190d..53c9430 100644
--- a/cairosdl.h
+++ b/cairosdl.h
@@ -29,2 +29,6 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* All cairo and cairosdl functions expect the underlying SDL_Surface
@@ -111,2 +115,5 @@ cairosdl_destroy (cairo_t *cr);
+#ifdef __cplusplus
+}
+#endif
#endif /* CAIROSDL_H */