例如,我一直看到使用和不使用解除引用的env接口指针
env->DoSomething(arguments)与
(*env)->DoSomething(env, arguments)他们真的是不同的东西吗? 是一个较旧的JNI实现吗?
I keep seeing the env interface pointer used with and without dereferencing, for example
env->DoSomething(arguments)vs.
(*env)->DoSomething(env, arguments)Are they actually different things? Is one from an older JNI implementation?
最满意答案
这是用维基百科在C和C ++中编写jni代码的区别:
请注意,C ++ JNI代码在语法上比C JNI代码稍微清晰,因为像Java一样,C ++使用对象方法调用语义。 这意味着在C中,使用(* env) - >取消引用env参数,并且必须将env显式传递给JNIEnv方法。 在C ++中,使用env->取消引用env参数,并且env参数作为对象方法调用语义的一部分隐式传递。
It's the difference between writing jni code in C and C++, from wikipedia:
Note that C++ JNI code is syntactically slightly cleaner than C JNI code because like Java, C++ uses object method invocation semantics. That means that in C, the env parameter is dereferenced using (*env)-> and env has to be explicitly passed to JNIEnv methods. In C++, the env parameter is dereferenced using env-> and the env parameter is implicitly passed as part of the object method invocation semantics.
更多推荐
发布评论