'friend' is quickly becoming an enemy.

closed account (3hM2Nwbp)
I'm having some issues with the friend keyword...and I'm pretty sure it has to do with the C linkage that I'm forced to use. Error below, and code that generates it to follow. Each of the commented lines fail, and I'm seemingly left with the C linkage to blame...but the friend keyword has nothing to do with linkage - at all...


Toolset = Microsoft V100 (Stock with VS2010)
error C2732: linkage specification contradicts earlier specification for 'X::Java_com_A_B_C_onKeyDown'


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class X
{
  //friend bool Java_com_A_B_C_onKeyDownkeyDown(JNIEnv*, jobject, bool, bool, char);
  //friend _declspec(dllexport) bool __stdcall Java_com_A_B_C_onKeyDownkeyDown(JNIEnv*, jobject, bool, bool, char);
  //friend _declspec(dllexport) bool Java_com_A_B_C_onKeyDownkeyDown(JNIEnv*, jobject, bool, bool, char);
  //friend bool __stdcall Java_com_A_B_C_onKeyDownkeyDown(JNIEnv*, jobject, bool, bool, char);
};

extern "C"
{
  _declspec(dllexport) bool __stdcall Java_com_A_B_C_onKeyDownkeyDown(JNIEnv*, jobject, bool, bool, char);
}

//...
//...

extern "C"
{
  _declspec(dllexport) bool __stdcall Java_com_A_B_C_onKeyDownkeyDownkeyDown(JNIEnv*, jobject, bool, bool, char)
  {
    // Do something extraordinarily interesting with the key press
  }
}


Thanks.

PS. Never deal with JNI, instead of stack traces, you get heap dumps. :(
Last edited on
closed account (DSLq5Di1)
Try moving the function declaration above your class definition.
Topic archived. No new replies allowed.