]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - utils/buildendian.c
More libc functions, and build-as-c fixes.
[polintos/scott/priv.git] / utils / buildendian.c
index d9b4e6ed86e4089271cfe1b0c60674eb8847ba51..f4026ae90ee68a17bd36c1b60badec2b38fecbba 100644 (file)
@@ -6,13 +6,14 @@ int main(void)
        union {
                uint32_t a;
                uint8_t b[4];
-       };
+       } u;
        
-       a = 0x12345678;
+       u.a = 0x12345678;
        
-       if (b[0] == 0x12 && b[1] == 0x34 && b[2] == 0x56 && b[3] == 0x78)
+       if (u.b[0] == 0x12 && u.b[1] == 0x34 && u.b[2] == 0x56 && u.b[3] == 0x78)
                printf("BE");
-       else if (b[3] == 0x12 && b[2] == 0x34 && b[1] == 0x56 && b[0] == 0x78)
+       else if (u.b[3] == 0x12 && u.b[2] == 0x34 &&
+                u.b[1] == 0x56 && u.b[0] == 0x78)
                printf("LE");
        else
                printf("UNKNOWN");