__ANDROID__ macro not defined

1,816 views
Skip to first unread message

Phil Endecott

unread,
Oct 15, 2010, 2:03:41 PM10/15/10
to android-ndk
Dear Experts,

I have the impression that __ANDROID__ should be defined, so that
platform-specific code can be enabled. But it doesn't seem to be:

$ /opt/android-ndk-r4b.1/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/
arm-eabi-g++ -E /tmp/empty.c -dM | grep __ANDROID__
$ /opt/android-ndk-r4-crystax/build/prebuilt/linux-x86/arm-eabi-4.4.0/
bin/arm-eabi-g++ -E /tmp/empty.c -dM | grep __ANDROID__

(no output from either)

What should I be doing differently? I've tried with --sysroot set,
with no effect; is there some other option that I need?

(I'm in the process of hacking the Makefiles for a few utility
libraries for cross-compilation. It's never quite as simple as just
changing the path to the compiler...)


Phil.

Doug Schaefer

unread,
Oct 15, 2010, 3:00:50 PM10/15/10
to andro...@googlegroups.com
The ndk-build script defines ANDROID. That's what I've been using.

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

Phil Endecott

unread,
Oct 15, 2010, 4:15:24 PM10/15/10
to android-ndk
It looks to me as if build/prebuilt/linux-x86/arm-eabi-4.4.0/lib/gcc/
arm-eabi/4.4.0/plugin/include/config/arm/eabi.h tries to define
__ANDROID__, but exactly how that file is used is not at all obvious.
It looks like it's something that should be included somewhere when
the compiler is built.

Tim Mensch

unread,
Oct 15, 2010, 4:45:04 PM10/15/10
to andro...@googlegroups.com
There was a thread on this before.

David Turner wrote:
> Sorry guys, seems to be a bug in the toolchain. I'll look for it.
>
> I would recommend defining __ANDROID__ explicitly for now, it should
> be the only thing that NDK users should be testing again.
>
> Thanks a lot for your time, sorry for the misinformation.
>
> - David

Tim

Phil Endecott

unread,
Oct 15, 2010, 4:52:21 PM10/15/10
to android-ndk
> There was a thread on this before.

Thanks Tim. (Searching for __ANDROID__ produced 831billion results,
"Did you mean ANDROID?"; but now I look again, I see that thread was
the first one...)

I think I'll be posting some more newbie questions over the weekend -
thank you all for your help so far.


Phil.

David Turner

unread,
Oct 23, 2010, 5:19:09 PM10/23/10
to andro...@googlegroups.com
To Clarify the situation:

The __ANDROID__ macro should be defined automatically by the compiler. In theory, this is the only thing you should test against, but there is a bug in the way our toolchain was configured/built that prevents this to work :-(

Also, the NDK build system uses -DANDROID when building C and C++ sources files for idiotic historical reasons. I would like to remove this in the future.

So in the end, as soon as r5 will be released, please only test against __ANDROID__, and forget about ANDROID.

Thanks for your time :-)
Reply all
Reply to author
Forward
0 new messages