Make wl_list_for_each* work for c++
authorJørgen Lind <jorgen.lind@nokia.com>
Tue, 13 Dec 2011 21:01:34 +0000 (22:01 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Wed, 14 Dec 2011 14:16:20 +0000 (09:16 -0500)
src/wayland-util.h

index 953d51a..625a2d3 100644 (file)
@@ -117,9 +117,15 @@ int wl_list_length(struct wl_list *list);
 int wl_list_empty(struct wl_list *list);
 void wl_list_insert_list(struct wl_list *list, struct wl_list *other);
 
+#ifdef __GNUC__
 #define __container_of(ptr, sample, member)                            \
-       (void *)((char *)(ptr)  -                                       \
+       (typeof(sample))((char *)(ptr)  -                               \
                 ((char *)&(sample)->member - (char *)(sample)))
+#else
+#define __container_of(ptr, sample, member)                            \
+       (void *)((char *)(ptr)  -                                       \
+                ((char *)&(sample)->member - (char *)(sample)))
+#endif
 
 #define wl_list_for_each(pos, head, member)                            \
        for (pos = 0, pos = __container_of((head)->next, pos, member);  \