Hi Simon, Thanks for the report.
> I think it helps, but it wasn't complete. Below is a new > backtrace. It seems the system wchar.h includes the system time.h, > which triggers the same problem... that may be harder to fix? > > arm-linux-androideabi-gcc > --sysroot /home/jas/android-ndk-r7/platforms/android-8/arch-arm > -DHAVE_CONFIG_H -I. -I.. -DGNULIB_STRICT_CHECKING=1 -g -O2 -MT > vasnprintf.o -MD -MP -MF .deps/vasnprintf.Tpo -c -o vasnprintf.o > vasnprintf.c > In file included > from > /home/jas/android-ndk-r7/platforms/android-8/arch-arm/usr/include/sys/time.h:33, > > from > /home/jas/android-ndk-r7/platforms/android-8/arch-arm/usr/include/time.h:32, > > from > /home/jas/android-ndk-r7/platforms/android-8/arch-arm/usr/include/wchar.h:39, > from ./wchar.h:81, > from ./stdint.h:531, > > from > /home/jas/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/sys/types.h:43, > > from > /home/jas/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:64, > from ./stdio.h:44, > from vasnprintf.c:71: > /home/jas/android-ndk-r7/platforms/android-8/arch-arm/usr/include/linux/time.h:20: > error: expected specifier-qualifier-list before 'time_t' I reproduce the same issue, after having tweaked stdint.h and wchar.h like Paul did: In file included from /cross/android-ndk-r7/platforms/android-8/arch-arm/usr/include/sys/time.h:33, from /cross/android-ndk-r7/platforms/android-8/arch-arm/usr/include/time.h:32, from /cross/android-ndk-r7/platforms/android-8/arch-arm/usr/include/wchar.h:39, from ./wchar.h:48, from ./stdint.h:531, from /cross/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/sys/types.h:43, from /cross/android-ndk-r7/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:64, from ./stdio.h:44, from ./wchar.h:72, from printf-args.h:42, from printf-args.c:30: /cross/android-ndk-r7/platforms/android-8/arch-arm/usr/include/linux/time.h:20: error: expected specifier-qualifier-list before 'time_t' Your analysis is right, and you have already nicely summarized in the subject: The problem is that include-fixed/sys/types.h contains at line 43: #include <stdint.h> at line 113: typedef __kernel_time_t time_t; So what we have to do, is to change our stdint.h replacement so that it avoids to #include any headers that might need time_t, if it is included from <sys/types.h>. There are two ways of implementing this: 1) Override sys/types.h also on android/bionic systems, so that it contains a #define _GL_INCLUDING_SYS_TYPES_H at the beginning and a #undef _GL_INCLUDING_SYS_TYPES_H at the end, and change stdint.h to just include the system's <stdint.h> when _GL_INCLUDING_SYS_TYPES_H is defined. Or (this is just a variant): Override sys/types.h also on android/bionic systems, so that it contains a #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H at the beginning and a #undef _GL_JUST_INCLUDE_SYSTEM_STDINT_H at the end. Our stdint.h already obeys _GL_JUST_INCLUDE_SYSTEM_STDINT_H. 2) Change stdint.h to just include the system's <stdint.h> when __BIONIC__ and _SYS_TYPES_H_ are defined but _SSIZE_T_DEFINED_ is not yet defined. The latter is simpler (does not require to override sys/types.h), so I'm applying that. > > Another possibility would be to remove all BSD/OS hacks in gnulib. > > BSD/OS hasn't been supported since 2004, according to Wikipedia, > > and perhaps it's time we retire it from gnulib. > > I wouldn't object to this, it was a long time since I heard anything > about BSD/OS. Actually it turns out that with the main problem fixed in stdint.h, Paul's changes are not needed. 2012-01-21 Bruno Haible <br...@clisp.org> stdint: Add support for Android. * lib/stdint.in.h: When included from Bionic <sys/types.h>, just include the system's <stdint.h>. Reported by Simon Josefsson <si...@josefsson.org>. --- lib/stdint.in.h.orig Sat Jan 21 13:08:10 2012 +++ lib/stdint.in.h Sat Jan 21 13:05:26 2012 @@ -34,6 +34,14 @@ <inttypes.h>. */ #define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H +/* On Android (Bionic libc), <sys/types.h> includes this file before + having defined 'time_t'. Therefore in this case avoid including + other system header files; just include the system's <stdint.h>. */ +#if defined __BIONIC__ \ + && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_ +# @INCLUDE_NEXT@ @NEXT_STDINT_H@ +#else + /* Get those types that are already defined in other system include files, so that we can "#define int8_t signed char" below without worrying about a later system include file containing a "typedef @@ -606,4 +614,5 @@ #endif #endif /* _@GUARD_PREFIX@_STDINT_H */ +#endif /* !(defined __BIONIC__ && ...) */ #endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */