Pointers JNA指针转换为结构
我在结构中有一个指针。我向这个指针传递了一个结构指针 但我无法将cast返回到这个指向struct的指针Pointers JNA指针转换为结构,pointers,casting,jna,Pointers,Casting,Jna,我在结构中有一个指针。我向这个指针传递了一个结构指针 但我无法将cast返回到这个指向struct的指针 public class Test { // Pointer ptr = new Memory(4); } public class Temp extends Structure { // } Test tst = new Test(); Temp tmp = new Temp(); tst.ptr = tmp.getPointer(); ...
public class Test
{
//
Pointer ptr = new Memory(4);
}
public class Temp extends Structure
{
//
}
Test tst = new Test();
Temp tmp = new Temp();
tst.ptr = tmp.getPointer();
...
Temp newTmp = (Temp)tst.ptr.getPointer(); // This is not working.
您需要使用构造函数在内存上创建一个新的结构:
Temp newTmp = new Temp(tst.ptr.getPointer());