如何将以下函数映射到Java?
void WriteToStruct(boolean[] Status, StructMsg RecBuff)
该函数的作用:
1)填充结构体RecBuff
2)更新状态
在Java中,如何映射布尔指针并访问函数更新的结构体数据?
我正在搜索与JNA和结构相关的另一个问题,谷歌将我重定向到这里。希望这可以帮助。
来自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);
您可以使用 ByReference 类来通过引用传递值。如果假定 BOOL 是 int,您可以使用 IntegerByReference。