我如何获得JNA结构数组的C指针

时间:2018-11-05 14:54:53

标签: java c binding jna

structTable是指向MyStruct的指针

MyStruct structs[3]; 
myobject.structTable = &structs[0]
myobject.structTableSize = 3;

我如何在Java中使用JNA?

1 个答案:

答案 0 :(得分:0)

含糊的问题。含糊的答案。如果您要创建新的/空的结构,则此方法应该起作用。

MyStruct struct = new MyStruct();
MyStruct[] structs = (MyStruct[]) struct.toArray(3);
myobject.structTable = structs; // Java Object pointing to structure array
long cPointer = Pointer.nativeValue(structs[0].getPointer()); // C pointer address