C
cppaddict
In JNI header files generated by javah, what is going on with the
'extern "C"' which is inserted around the native method when
"cplusplus" is defined.
I would think you would only need extern "C" when cplusplus wasn't
defined, ie, when you were using C and not C++.
I want to implement my native methods in C++. Can I do this when
they're wrapped by extern "C"? If so, what exactly is extern "C"
doing?
Thanks for any clarification,
cpp
Here is sample JNI header file, if the above wasn't clear:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
'extern "C"' which is inserted around the native method when
"cplusplus" is defined.
I would think you would only need extern "C" when cplusplus wasn't
defined, ie, when you were using C and not C++.
I want to implement my native methods in C++. Can I do this when
they're wrapped by extern "C"? If so, what exactly is extern "C"
doing?
Thanks for any clarification,
cpp
Here is sample JNI header file, if the above wasn't clear:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif