From: Peter Korn <###@###.###>
Subject: Sharing constants between Java and Windows
To: ###@###.###
Hi,
I want to define some constants (static finals) in Java that then, through
the magic of JNI, I can reference from my Windows native methods.
Fer instance, I have the file "blah.java":
package foo.bar;
class blah {
static final long bleh = 1;
public blah() {}
public native void huh();
}
which then results in the header file (through the magic of JNI)
foo_bar_blah.h:
...
#ifdef __cplusplus
extern "C" {
#endif
#undef foo_bar_blah_bleh
#define foo_far_blah_bleh 1LL
...
So then I create my code blah.cpp, which wants to compare a jlong variable
to the constant:
...
if (myJLongVar == (jlong) foo_far_blah_bleh) {
...
But I get a series of compile errors from MSDev 5.0:
"error C2059: bad suffix on number"
"error C2146: missing ')' before identifier 'L'"
"error C2059: syntax error : ')'"
"error C2065: 'L' : undeclared identifier"
"error C2143: syntax error : missing ';' before '{'"
any ideas as to what I'm doing wrong? Is javah generating header files that
MSDev 5.0 can't parse? Are there compiler options I should be using to get
it to handle "#define foo_far_blah_bleh 1LL"?
Thanks,
Peter
Subject: Sharing constants between Java and Windows
To: ###@###.###
Hi,
I want to define some constants (static finals) in Java that then, through
the magic of JNI, I can reference from my Windows native methods.
Fer instance, I have the file "blah.java":
package foo.bar;
class blah {
static final long bleh = 1;
public blah() {}
public native void huh();
}
which then results in the header file (through the magic of JNI)
foo_bar_blah.h:
...
#ifdef __cplusplus
extern "C" {
#endif
#undef foo_bar_blah_bleh
#define foo_far_blah_bleh 1LL
...
So then I create my code blah.cpp, which wants to compare a jlong variable
to the constant:
...
if (myJLongVar == (jlong) foo_far_blah_bleh) {
...
But I get a series of compile errors from MSDev 5.0:
"error C2059: bad suffix on number"
"error C2146: missing ')' before identifier 'L'"
"error C2059: syntax error : ')'"
"error C2065: 'L' : undeclared identifier"
"error C2143: syntax error : missing ';' before '{'"
any ideas as to what I'm doing wrong? Is javah generating header files that
MSDev 5.0 can't parse? Are there compiler options I should be using to get
it to handle "#define foo_far_blah_bleh 1LL"?
Thanks,
Peter
- relates to
-
JDK-4451616 for data type long javah generates extention i64 on windows OS
-
- Closed
-
-
JDK-5085132 cross-compilation capability for `javac -h`
-
- Open
-