[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sys/types.h on Android includes stdint.h before defining time_t
From: |
Bruno Haible |
Subject: |
Re: sys/types.h on Android includes stdint.h before defining time_t |
Date: |
Tue, 24 Jan 2012 12:29:55 +0100 |
User-agent: |
KMail/4.7.4 (Linux/3.1.0-1.2-desktop; KDE/4.7.4; x86_64; ; ) |
Simon Josefsson wrote:
> It failed directly in accept4.c with this backtrace:
>
> depbase=`echo accept4.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> arm-linux-androideabi-gcc --sysroot
> /home/jas/android-ndk-r7/platforms/android-14/arch-arm -std=gnu99
> -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" -I.
> -I.. -DGNULIB_STRICT_CHECKING=1 -I../intl -fvisibility=hidden -g -O2 -MT
> accept4.o -MD -MP -MF $depbase.Tpo -c -o accept4.o accept4.c &&\
> mv -f $depbase.Tpo $depbase.Po
> In file included from
> /home/jas/android-ndk-r7/platforms/android-14/arch-arm/usr/include/sys/time.h:33,
> from ./sys/time.h:39,
> from
> /home/jas/android-ndk-r7/platforms/android-14/arch-arm/usr/include/time.h:32,
> from ./time.h:40,
> from ./stdint.h:535,
> 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 ./sys/types.h:28,
> from ./sys/socket.h:52,
> from accept4.c:21:
> /home/jas/android-ndk-r7/platforms/android-14/arch-arm/usr/include/linux/time.h:20:
> error: expected specifier-qualifier-list before 'time_t'
> /home/jas/android-ndk-r7/platforms/android-14/arch-arm/usr/include/linux/time.h:26:
> error: expected specifier-qualifier-list before 'time_t'
>
> The reason appears to be that __BIONIC__ isn't defined for this
> include-path. Indeed, it seems __ANDROID__ may be a better symbol to
> check for? See this:
>
> address@hidden:~$ cat foo.c
> #if defined __BIONIC__
> #warning foo
> #endif
> #if defined __ANDROID__
> #warning bar
> #endif
Yes. If <sys/cdefs.h> has not been included at this point,
from accept4.c to sys/socket.h to sys/types.h to stdint.h, it is better
to test __ANDROID__ instead of __BIONIC__.
I wished we could test __BIONIC__, because "Bionic" is the name of the
libc with its include files, whereas "Android" is a marketing name.
Marketing names can change, and a libc can also be adopted by different
projects.
> other system header files; just include the system's <stdint.h>. */
> -#if defined __BIONIC__ \
> +#if (defined __BIONIC__ || defined __ANDROID__) \
> && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_
If "Android" was to be renamed to something else, or Bionic adopted by
a different project, __BIONIC__ and __ANDROID__ would end up undefined
here. So we would need a fix at this place again anyway. => Testing
__BIONIC__ here is redundant. I'm applying this:
2012-01-24 Bruno Haible <address@hidden>
stdint: Improve support for Android.
* lib/stdint.in.h: Test __ANDROID__, not __BIONIC__.
Reported by Simon Josefsson <address@hidden>.
--- lib/stdint.in.h.orig Tue Jan 24 12:21:28 2012
+++ lib/stdint.in.h Tue Jan 24 12:20:35 2012
@@ -36,8 +36,10 @@
/* 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__ \
+ other system header files; just include the system's <stdint.h>.
+ Ideally we should test __BIONIC__ here, but it is only defined after
+ <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
+#if defined __ANDROID__ \
&& defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_
# @INCLUDE_NEXT@ @NEXT_STDINT_H@
#else
@@ -614,5 +616,5 @@
#endif
#endif /* address@hidden@_STDINT_H */
-#endif /* !(defined __BIONIC__ && ...) */
+#endif /* !(defined __ANDROID__ && ...) */
#endif /* !defined address@hidden@_STDINT_H && !defined
_GL_JUST_INCLUDE_SYSTEM_STDINT_H */
- sys/types.h on Android includes stdint.h before defining time_t, Simon Josefsson, 2012/01/20
- Re: sys/types.h on Android includes stdint.h before defining time_t, Hans-Christoph Steiner, 2012/01/23
- Re: sys/types.h on Android includes stdint.h before defining time_t, Hans-Christoph Steiner, 2012/01/26
- Re: sys/types.h on Android includes stdint.h before defining time_t, Paul Eggert, 2012/01/26
- Re: sys/types.h on Android includes stdint.h before defining time_t, Hans-Christoph Steiner, 2012/01/26
- Re: sys/types.h on Android includes stdint.h before defining time_t, Simon Josefsson, 2012/01/27
- Re: sys/types.h on Android includes stdint.h before defining time_t, Hans-Christoph Steiner, 2012/01/27
- Re: sys/types.h on Android includes stdint.h before defining time_t, Werner Koch, 2012/01/27