[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: Simon Josefsson
Subject: Re: sys/types.h on Android includes stdint.h before defining time_t
Date: Mon, 23 Jan 2012 16:57:22 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.92 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> Bruno Haible <address@hidden> writes:
>> 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.
> Thank you Bruno, I can confirm that it works.  I'm now trying to build
> more of gnulib for Android, let's see what breaks...

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 
 -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 
                 from ./sys/time.h:39,
                 from ./time.h:40,
                 from ./stdint.h:535,
                 from ./sys/types.h:28,
                 from ./sys/socket.h:52,
                 from accept4.c:21:
 error: expected specifier-qualifier-list before 'time_t'
 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
#if defined __ANDROID__
#warning bar
address@hidden:~$ arm-linux-androideabi-gcc --sysroot 
/home/jas/android-ndk-r7/platforms/android-8/arch-arm -o foo foo.c
foo.c:5:2: warning: #warning bar
 In function `_start':
(.text+0x14): undefined reference to `main'
collect2: ld returned 1 exit status

With a patch like the one below, it works.  However, maybe the
__BIONIC__ test is redundant and should be removed?

With this, the majority of gnulib does compile, but there are several
compile failures.


diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 591371c..4b156c1 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -37,7 +37,7 @@
 /* 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__ \
+#if (defined __BIONIC__ || defined __ANDROID__) \
     && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_

reply via email to

[Prev in Thread] Current Thread [Next in Thread]