JNA 无符号整数引用给出了奇怪的结果
我目前正在尝试使用 JNA 访问 C API。但我对通过引用传递的无符号整数参数有问题。
所以这里是有问题的 C 函数:
int EE_DataGetNumberOfSample(DataHandle hData, unsigned int* nSampleOut);
在 Java 中我有:
public int EE_DataGetNumberOfSample(Pointer hData, ByReference nSampleOut);
下面是我如何使用它:
IntByReference nSamplesTaken = new IntByReference();
edk.EE_DataGetNumberOfSample(hData.getValue(), nSamplesTaken);
int nativeNSamplesTaken = nSamplesTaken.getValue();
System.out.println(Integer.toBinaryString(nativeNSamplesTaken)+"("+nativeNSamplesTaken+")");
这给了我:
11000100110110010011000000(51602624)
虽然它应该是0。
我使用JNA-API的方式有问题吗?
谢谢你!
I'm currently trying to access a C API using JNA. But I have a problem with unsigned integer parameters that are being passed by reference.
So here is the C function in question:
int EE_DataGetNumberOfSample(DataHandle hData, unsigned int* nSampleOut);
In Java I have:
public int EE_DataGetNumberOfSample(Pointer hData, ByReference nSampleOut);
And here's how I'm using it:
IntByReference nSamplesTaken = new IntByReference();
edk.EE_DataGetNumberOfSample(hData.getValue(), nSamplesTaken);
int nativeNSamplesTaken = nSamplesTaken.getValue();
System.out.println(Integer.toBinaryString(nativeNSamplesTaken)+"("+nativeNSamplesTaken+")");
This gives me:
11000100110110010011000000(51602624)
Altough it should be 0.
Is there something wrong with the way I'm using the JNA-API?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:
我在这里发布的代码片段没有任何问题,但还有另一个完全不相关的错误,与问题无关。
[关闭]
To answer my own question:
There's nothing wrong with the code snippets I posted here, but there was another completely unrelated error that has nothing to do with the question.
[closed]