From cd9475bfe51e5973f23601c6e51b333ea7883fbd Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 27 Jan 2013 22:50:59 +0200 Subject: [PATCH] Simpler endianness tester. --- test cases/26 endian/prog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test cases/26 endian/prog.c b/test cases/26 endian/prog.c index 261ac0fb9..b2a10d081 100644 --- a/test cases/26 endian/prog.c +++ b/test cases/26 endian/prog.c @@ -1,12 +1,10 @@ #include int is_big_endian(void) { - union { - uint32_t i; - char c[4]; - } bint = {0x01020304}; - - return bint.c[0] == 1; + uint32_t one = 1; + if(*((uint8_t*) &one) == 1) + return 0; + return 1; }