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

徘徊边缘 提交于 2019-12-04 11:15:58

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7414355/is-it-safe-to-build-with-fsigned-char-with-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!