stdint.h: Make it work with my GCC 4.3.3/GLIBC 2.9 toolchain
authorHolger Hans Peter Freyther <zecke@selfish.org>
Fri, 5 Mar 2010 17:41:29 +0000 (18:41 +0100)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Mon, 8 Mar 2010 03:36:36 +0000 (04:36 +0100)
The compiler complains about seing two conflicting definitions
for int32_t and the compile will stop. One definitions comes from
here and the other is coming from sys/types.h.

One option would be to try to use unsigned int and signed int
instead of using a long and see if that is matching, the other
option is to include the real libc stdint.h header and see if
it has defined a uint32_t for us.

src/target/firmware/include/stdint.h

index 7b1400a..9690799 100644 (file)
@@ -1,9 +1,18 @@
-#ifndef _STDINT_H
-#define _STDINT_H
+#ifndef OSMO_STDINT_H
+#define OSMO_STDINT_H
 
 /* some older toolchains (like gnuarm-3.x) don't provide a C99
    compliant stdint.h yet, so we define our own here */
 
+/* to make matters worse newer gcc with glibc headers have
+   a incompatible definition of these types. We will use the
+   gcc'ism of #include_next to include the compiler's libc
+   header file and then check if it has defined int8_t and
+   if not we will use our own typedefs */
+
+#include_next <stdint.h>
+
+#ifndef __int8_t_defined
 typedef signed char int8_t;
 typedef unsigned char uint8_t;
 
@@ -15,5 +24,6 @@ typedef unsigned int uint32_t;
 
 typedef long long int int64_t;
 typedef unsigned long long int uint64_t;
+#endif
 
 #endif