cedric pushed a commit to branch master.

commit f6ba1f69e7ef3d600354e7747c2a223fb3ece02c
Author: Ryuan Choi <[email protected]>
Date:   Fri Jul 26 14:00:16 2013 +0900

    eina: use __typeof__ for public headers to build applications with c++0x.
---
 src/lib/eina/eina_inarray.h | 33 ++++++++++++++++++++++++---------
 src/lib/eina/eina_inlist.h  | 17 +++++++++++++----
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/lib/eina/eina_inarray.h b/src/lib/eina/eina_inarray.h
index aa9a97f..1599f03 100644
--- a/src/lib/eina/eina_inarray.h
+++ b/src/lib/eina/eina_inarray.h
@@ -685,10 +685,17 @@ EAPI Eina_Accessor *eina_inarray_accessor_new(const 
Eina_Inarray *array) EINA_MA
  *
  * @since 1.2
  */
-#define EINA_INARRAY_FOREACH(array, itr)                                \
-  for ((itr) = (array)->members;                                       \
-       (itr) < (((typeof(*itr)*)(array)->members) + (array)->len);     \
-       (itr)++)
+#ifdef __GNUC__
+# define EINA_INARRAY_FOREACH(array, itr)                                \
+   for ((itr) = (array)->members;                                      \
+        (itr) < (((__typeof__(*itr)*)(array)->members) + (array)->len);        
\
+        (itr)++)
+#else
+# define EINA_INARRAY_FOREACH(array, itr)                                \
+   for ((itr) = (array)->members;                                      \
+        (itr) < (((typeof(*itr)*)(array)->members) + (array)->len);    \
+        (itr)++)
+#endif
 
 /**
  * @def EINA_INARRAY_REVERSE_FOREACH
@@ -706,11 +713,19 @@ EAPI Eina_Accessor *eina_inarray_accessor_new(const 
Eina_Inarray *array) EINA_MA
  *
  * @since 1.2
  */
-#define EINA_INARRAY_REVERSE_FOREACH(array, itr)                        \
-  for ((itr) = ((((typeof(*(itr))*)(array)->members) + (array)->len) - 1); \
-       (((itr) >= (typeof(*(itr))*)(array)->members)                   \
-        && ((array)->members != NULL));                                        
\
-       (itr)--)
+#ifdef __GNUC__
+# define EINA_INARRAY_REVERSE_FOREACH(array, itr)                        \
+   for ((itr) = ((((__typeof__(*(itr))*)(array)->members) + (array)->len) - 
1); \
+        (((itr) >= (__typeof__(*(itr))*)(array)->members)                      
\
+         && ((array)->members != NULL));                                       
\
+        (itr)--)
+#else
+# define EINA_INARRAY_REVERSE_FOREACH(array, itr)                        \
+   for ((itr) = ((((typeof(*(itr))*)(array)->members) + (array)->len) - 1); \
+        (((itr) >= (typeof(*(itr))*)(array)->members)                  \
+         && ((array)->members != NULL));                                       
\
+        (itr)--)
+#endif
 
 /**
  * @}
diff --git a/src/lib/eina/eina_inlist.h b/src/lib/eina/eina_inlist.h
index a87b744..263d8d7 100644
--- a/src/lib/eina/eina_inlist.h
+++ b/src/lib/eina/eina_inlist.h
@@ -818,8 +818,13 @@ EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, 
Eina_Compare_Cb func);
  * 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) - \
+# ifdef __GNUC__
+#  define _EINA_INLIST_CONTAINER(ref, ptr) (__typeof__(ref))((char *)(ptr) - \
                                                   _EINA_INLIST_OFFSET(ref))
+# else
+#  define _EINA_INLIST_CONTAINER(ref, ptr) (typeof(ref))((char *)(ptr) - \
+                                                  _EINA_INLIST_OFFSET(ref))
+# endif
 #endif
 
 /**
@@ -868,9 +873,13 @@ EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, 
Eina_Compare_Cb func);
  * don't remove all items from the list.
  * @since 1.8
  */
-#define EINA_INLIST_FREE(list, it)                             \
-  for (it = (typeof(it)) list; list; it = (typeof(it)) list)   \
-
+#ifdef __GNUC__
+# define EINA_INLIST_FREE(list, it)                            \
+   for (it = (__typeof__(it)) list; list; it = (__typeof__(it)) list)
+#else
+# define EINA_INLIST_FREE(list, it)                            \
+   for (it = (typeof(it)) list; list; it = (typeof(it)) list)
+#endif
 
 
 #include "eina_inline_inlist.x"

-- 

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk

Reply via email to