when to use JNIEXPORT and JNICALL in Android NDK?

前端 未结 4 2194
甜味超标
甜味超标 2020-12-13 14:22

I\'m trying to write my own jni sources. Looking at some ndk samples, I found that they often use those macros JNIEXPORT and JNICALL follewed by the name of java package lik

4条回答
  •  情深已故
    2020-12-13 15:09

    You can find the definition of those macros in the machine-dependent portion of your JNI includes (usually in $JAVA_HOME/include//jni-md.h).

    In short, JNIEXPORT contains any compiler directives required to ensure that the given function is exported properly. On android (and other linux-based systems), that'll be empty.

    JNICALL contains any compiler directives required to ensure that the given function is treated with the proper calling convention. Probably empty on android as well (it's __stdcall on w32).

    In general, you should leave them in, even if they're empty #defines.

提交回复
热议问题