diff endianchk.c @ 0:8e7e08bf7b9e

Initial import.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 24 Sep 2014 21:20:04 +0300
parents
children 9a0aeb9ce9ba
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/endianchk.c	Wed Sep 24 21:20:04 2014 +0300
@@ -0,0 +1,22 @@
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+    int val = 1, ret;
+    char *s = (char *) &val;
+    (void) argc;
+    (void) argv;
+    ret = (int)(*s);
+    printf(
+        "#ifndef MY_CONFIG_H\n"
+        "#define MY_CONFIG_H 1\n"
+        "\n"
+        "#define TH_BYTEORDER TH_%s_ENDIAN\n"
+        "\n"
+        "#endif /* MY_CONFIG_H */\n"
+        ,
+        ret ? "LITTLE" : "BIG"
+        );
+    return 0;
+}
+