转换JNI类型本地类型 [英] Convert JNI types to Native types
问题描述
虽然有关于转动的jstring到本机的字符串(字符串nativeString = env-> GetStringUTFChars(jStringVariable,NULL);
)的文件我找不到例如,将一个jboolean转换为布尔或jint为int。
While there is documentation regarding turning a jstring to a native string (string nativeString = env->GetStringUTFChars(jStringVariable, NULL);
) I can't find an example which will convert a jboolean to a bool or a jint to an int.
任何人都可以表明这是如何实现的?
Can anyone suggest how this is achieved?
推荐答案
您只需要投 jint
到 INT
使用C风格的转换。同为 jboolean
到布尔
(如果你使用C99 布尔
输入)或 uint8_t有
(如果你使用std int型)或 unsigned char型
。
You just need to cast jint
to int
using C style casts. Same for jboolean
to bool
(if you're using C99 bool
type) or to uint8_t
(if you're using std int types) or to unsigned char
.
打开 $ NDK_ROOT /平台/ Android的-8 /弓臂/ usr / include目录/ jni.h
,你会看到 jint
, jboolean
等只是的typedef
秒。
Open $NDK_ROOT/platforms/android-8/arch-arm/usr/include/jni.h
and you'll see jint
, jboolean
etc are just typedef
s.
这篇关于转换JNI类型本地类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!