How to use unsigned int to be able to use a function for JNA (Java Native Interface)?
I'm using JNA in order to use a C++ library in my Java application. I am using an interface in Java to use these functions. The function uses three arguments in C++: an unsigned int, a const char*, and a long*. JNA implements Strings (according to their documents) in Java to pass in a char*. Likewise, it uses a long[] to pass in a long*. I'm confused, however, about the type that I should pass in for the unsigned int. The char* that is passed in represents the name of the file, and no matter what type I use for the first argument, it does not seem to recognize the file. Furthermore, the last, long type actually returns a value after the function is executed. If I use the short or int type for the first argument, this number seems to be correct, however, if I use the long type for the first argument, it is incorrect. Can anyone help?
For a开发者_Go百科n example, here's what the actual prototype in C++ is followed by what I currently have as the interface prototype in Java:
int JrConnect(unsigned int id, const char* config_file, long* handle);
public int JrConnect(int[] id, String[] config_file, long[] handle);
Use JNA's IntByReference.
精彩评论