开发者

How to use unsigned int to be able to use a function for JNA (Java Native Interface)?

开发者 https://www.devze.com 2023-02-23 13:37 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号