开发者

Android NDK C #ifndef problems

I am using the NDK-r6 on Windows and want to compile a simple C program for testing purposes. Just compiling a C console program is not this easy, but I got the needed options. The command line I use is (in cygwin):

 /cygdrive/f/android/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-gcc
-fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__
-D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te
-mtune=xscale -msoft-float -mthumb -Os  -funroll-all-loops -fomit-frame-pointer
-fno-strict-aliasing -finline-limit=64 -IF:/android_ws/stkeys/jni -DANDROID  
-Wa,--no开发者_如何学JAVAexecstack -O3 -DNDEBUG -g -Wl,
-rpath-link=/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib 
-L/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib -nostdlib
/android/android-ndk-r6/platforms/android-5/arch-arm/usr/lib/crtbegin_dynamic.o 
-lc -IF:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include
F:/android_ws/stkeys/jni/stkeys.c F:/android_ws/stkeys/jni/sha1.c
-o F:/android_ws/stkeys/jni/stkeys

One hell of a commandline, but it works. The problem is, that this code breaks:

#ifndef uint32_t
typedef unsigned int uint32_t;
#endif

#ifndef uint8_t
typedef unsigned char uint8_t;
#endif

This are the errors:

In file included from F:/android_ws/stkeys/jni/stkeys.c:44:
F:/android_ws/stkeys/jni/sha1.h:23: error: redefinition of typedef 'uint32_t'
F:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include/stdint.h:53:
note: previous declaration of 'uint32_t' was here
F:/android_ws/stkeys/jni/sha1.h:27: error: redefinition of typedef 'uint8_t'
F:/android/android-ndk-r6/platforms/android-5/arch-arm/usr/include/stdint.h:49:
note: previous declaration of 'uint8_t' was here

I got it to compile by commenting out the definitions of uint32_t etc. in stdint.h, but this can't be the solution. Is this a bug in the NDK, or am I doing something wrong here?


It obviously isn't expecting stdint.h to be included. Don't know why.

The test #ifndef only works for testing if something has been #defined. There is no way to do typedefs conditionally.

I would rather hack the application code than the standard headers. :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜