diff options
Diffstat (limited to 'autoconfig.cpp')
-rw-r--r-- | autoconfig.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/autoconfig.cpp b/autoconfig.cpp new file mode 100644 index 0000000..aa8b6a4 --- /dev/null +++ b/autoconfig.cpp | |||
@@ -0,0 +1,30 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <stdio.h> | ||
3 | |||
4 | void detectEndianness() | ||
5 | { | ||
6 | uint16_t x=0x0100; | ||
7 | fprintf( stderr, | ||
8 | "#define LITTLE_ENDIAN 0\n" | ||
9 | "#define BIG_ENDIAN 1\n" | ||
10 | "#define ENDIANNESS %d\n\n", | ||
11 | ((uint8_t *)&x)[0] | ||
12 | ); | ||
13 | printf("Archetecture is: %s Endian\n", ((uint8_t *)&x)[0]?"Big":"Little" ); | ||
14 | } | ||
15 | |||
16 | int main() | ||
17 | { | ||
18 | fprintf( stderr, | ||
19 | "#ifndef BU_AUTO_CONFIG_H\n" | ||
20 | "#define BU_AUTO_CONFIG_H\n\n" | ||
21 | ); | ||
22 | |||
23 | // huh, turns out #include <endian.h> covers this... | ||
24 | // detectEndianness(); | ||
25 | |||
26 | fprintf( stderr, "#endif\n"); | ||
27 | |||
28 | return 0; | ||
29 | } | ||
30 | |||