gpt4 book ai didi

java - JNA 结构和指针映射

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:07:58 24 4
gpt4 key购买 nike

如何将下面的函数映射到java?

VOID WriteToStruct(BOOL *Status, STRUCT_MSG RecBuff)

这个函数的作用:
1) 填充结构 RecBuff
2) 更新状态

如何映射到 Java 中的 boolean 指针并访问函数更新的结构数据?

最佳答案

我正在搜索另一个关于 JNA 和结构的问题,Google 将我重定向到这里。我希望这会有所帮助。

来自 JNA API

To pass a structure by value, first define the structure, then define an empty class from that which implements Structure.ByValue. Use the ByValue class as the argument or return type.

// Original C code
typedef struct _Point {
int x, y;
} Point;

Point translate(Point pt, int dx, int dy);

// Equivalent JNA mapping
class Point extends Structure {
public static class ByValue extends Point implements Structure.ByValue { }
public int x, y;
}
Point.ByValue translate(Point.ByValue pt, int x, int y);
...
Point.ByValue pt = new Point.ByValue();
Point result = translate(pt, 100, 100);

关于java - JNA 结构和指针映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/494325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com