Want to make wchar_t be unsigned short using Android NDK

wchar_t is reportedly useless and not supported in Android NDK development. If so, then what do I need to do so that wchar_t is defined as unsigned short?

This would greatly facilitate porting on top of the built-in library that references wchar_t, and would also better fit the JNI understanding of Unicode. GetStringUTFChars () returns const char *, and GetStringChars () returns const jchar *, where jchar is defined as unsigned short (2 bytes). Defining wchar_t as unsigned short will make it compatible with GetStringChars () and seemingly make my life a lot easier.

Is it possible? What would it take? I think this will require breaking and restoring the tool chain.

+1
source share
1 answer

gcc knows the -fshort-wchar option. I do not know if this compiler in Android supports this option.

I believe that if your native library uses the extensive string functions of C-RTL? In this case, you need to provide these implementations yourself.

+1
source

Source: https://habr.com/ru/post/885698/


All Articles