From: lucas Date: Fri, 23 Sep 2011 17:02:02 +0000 (+0000) Subject: eina: provide a C++-compatible version of _EINA_INLIST_CONTAINER X-Git-Tag: 2.0_alpha~61^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e36396171d05d3c1528f87844db7b944dc72b970;p=framework%2Fuifw%2Feina.git eina: provide a C++-compatible version of _EINA_INLIST_CONTAINER In C++ we can't assign a void pointer to another type pointer without casts. We now rely on typeof() operator *when using C++*. We may provide another version later for those compilers without typeof() support. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@63568 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/include/eina_inlist.h b/src/include/eina_inlist.h index 75207dc..1b3ab27 100644 --- a/src/include/eina_inlist.h +++ b/src/include/eina_inlist.h @@ -774,8 +774,18 @@ EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func); /* This two macros are helpers for the _FOREACH ones, don't use them */ #define _EINA_INLIST_OFFSET(ref) ((char *)&(ref)->__in_list - (char *)(ref)) + +#if !defined(__cplusplus) #define _EINA_INLIST_CONTAINER(ref, ptr) (void *)((char *)(ptr) - \ _EINA_INLIST_OFFSET(ref)) +#else +/* + * In C++ we can't assign a "type*" pointer to void* so we rely on GCC's typeof + * operator. + */ +#define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \ + _EINA_INLIST_OFFSET(ref)) +#endif #define EINA_INLIST_FOREACH(list, l) \ for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \