开发者

JNA Pointer cast to struct

开发者 https://www.devze.com 2023-01-12 01:35 出处:网络
I have a pointer in a struct. And I passed a struct pointer to this pointer. But I could not type cast back to this pointer to struct.

I have a pointer in a struct. And I passed a struct pointer to this pointer.

But I could not type cast back to this pointer to struct.

public class Test
{

     //
     Pointer pt开发者_如何学Gor = 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.


You need to create a new structure cast onto the memory using the Structure(Pointer p) constructor:

Temp newTmp = new Temp(tst.ptr.getPointer());
0

精彩评论

暂无评论...
验证码 换一张
取 消