Alex Cohn
unread,Aug 29, 2012, 6:40:31 AM8/29/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to android-ndk
NDK allows mixing C and C++ files in a single project (e.g. to create
a shared library). Unfortunately, it does not allow to specify C-
language specific compilation flags. This is rarely necessary, but one
case I found recently was when the C files expected -std=c99 and C++
depended on -std=c++0x.
Simply defining
LOCAL_CFLAGS += -std=c99
LOCAL_CPPFLAGS += -std=c++0x
would not work nicely, because each C++ compilation will issue the
warning
cc1plus: warning: command line option "-std=c99" is valid for C/
ObjC but not for C++
Luckily, I have found an ugly workaround: instead of setting
LOCAL_CFLAGS, add the following two lines to your Android.mk
LOCAL_C99_FILES := $(filter %.c, $(LOCAL_SRC_FILES))
TARGET-process-src-files-tags += $(call add-src-files-target-
cflags, $(LOCAL_C99_FILES), -std=c99)
This works for me for NDK r8b, but I hope there will be better ways in
the future.
I have made no effort to check compatibility of this hack with older
versions of NDK.