[gjs] arg.c: Integer array conversion: Avoid use of zero-sized C arrays in unions



commit ec81410f539dfc90d3928c3cc6c0502d374907b8
Author: Colin Walters <walters verbum org>
Date:   Mon Jul 18 11:56:54 2011 -0400

    arg.c: Integer array conversion: Avoid use of zero-sized C arrays in unions
    
    SunCC apparently refuses to compile with these.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=595447

 gi/arg.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gi/arg.c b/gi/arg.c
index 3390be4..d73e3dd 100644
--- a/gi/arg.c
+++ b/gi/arg.c
@@ -526,7 +526,7 @@ gjs_array_to_intarray(JSContext   *context,
 {
     /* nasty union types in an attempt to unify the various int types */
     union { guint32 u; gint32 i; } intval;
-    union { guint8 u8[0]; guint16 u16[0]; guint32 u32[0]; } *result;
+    void *result;
     unsigned i;
 
     /* add one so we're always zero terminated */
@@ -560,11 +560,11 @@ gjs_array_to_intarray(JSContext   *context,
         /* Note that this is truncating assignment. */
         switch (intsize) {
         case 1:
-            result->u8[i] = (gint8) intval.u; break;
+            ((guint8*)result)[i] = (gint8) intval.u; break;
         case 2:
-            result->u16[i] = (gint16) intval.u; break;
+            ((guint16*)result)[i] = (gint16) intval.u; break;
         case 4:
-            result->u32[i] = (gint32) intval.u; break;
+            ((guint32*)result)[i] = (gint32) intval.u; break;
         default:
             g_assert_not_reached();
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]