Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to build with -fsigned-char with Android NDK?

For consistency with other platforms, I need to use signed char in some native code I'm working on. But by default on Android NDK char type is unsigned.

I have tried to explicitly use signed char type but it generates too many warnings differ in signedness when string constant/library functions are involved, so I'm looking to build my code with -fsigned-char.

I'm now trying to anticipate problems regarding Android ARM ABI and API when -fsigned-char is used, but I can't find any problem yet.

In Procedure Call Standard for the ARM Architecture ABI (AAPCS), 7.1.1 Arithmetic Types, and C Library ABI for the ARM Architecture , 5.6 inttypes.h, char is said to be unsigned.

Did you know if there Will be some trouble when using C library (others libraries available on Android) when -fsigned-char is enabled in Android NDK?

like image 506
Yann Droneaud Avatar asked Sep 14 '11 09:09

Yann Droneaud


1 Answers

I have also encountered this issue tonight. char is treat as signed on x86, but changed to unsigned when run on Android device. This make my JNI libs don't work properly.

After setting LOCAL_CFLAGS := -fsigned-char in Android.mk, my program works! Currently I found no side effect. Thanks.

like image 72
pengguang001 Avatar answered Nov 14 '22 22:11

pengguang001