Domain/Android 2011.09.15 10:24
Most Android device is 32bit machine. So, many application assumes that host machine is 32bit system.
And in general, there is no difference developing Android-natvie-library between 64bit and 32bit build machine.
But, here is usual step for developing Android-native-library.
(1) Developing and verifying code at build machine.
(2) Porting to NDK build system.
Most developers turns on full-warning-option at compile to detect bugs at early stage.
But, building and verifying codes assuming 32bit host machine at 64bit machine always issues type casting warning due to different type size.
Especially, between pointer and integer.
For example, many Android JAVA application uses int - jint - as a type to contain native pointer with assumption of 32bit-host-system.
Building this code at 64bit build system to verify code issues type casting warning, even if code itself is built perfectly at NDK build system.
And it is worse that this code doesn't work at 64bit Android host machine, even though it is not popular.
To reduce this warnings (for easy-verifying of library code at build machine), in my opinion, using long - jlong - instead of jint as a type for containing native pointer is better unless memory space is extremely critical.
And to make compiler be happy, using macro can be a good choice.
Here is example of macro for type-casting between pointer and integer - jlong.
(This sample works well without warning at 32bit/64bit build/host system).
#define ptr2jlong(v) ((jlong)((intptr_t)(v)))
#define jlong2ptr(v) ((void*)((intptr_t)(v)))
This is just simple example for portability issues.
Making portable code is always very difficult...
|Policy of Google Play to consider registering App to Android Google Play. (0)||2012.10.04|
|Points to consider for recycling Bitmap of ImageView. (0)||2012.09.21|
|[Android] Developing Android-native-library on 64bit build machine (0)||2011.09.15|
|[Android] Creating minimum set of Android (Kernel + adbd + ueventd) for Android kernel test. (0)||2011.05.31|
|[Android] Managing service... (0)||2011.05.02|
|[Android] Handling kernel device uevent in userspace. (0)||2011.04.20|