美文网首页
Jna send pointer pointer to c++

Jna send pointer pointer to c++

作者: 潭潭_180 | 来源:发表于2018-12-20 19:02 被阅读0次

目的:

有这样一个需求,java通过jna传递指针数组给c++,或者指针的指针

解决方案:

c++ :

声明 void test1(class ** c1,int len);

jna:

声明:void test1(Pointer p,int len);

java使用

//Pointer是代表指针

int size = Native.getNativeSize(Pointer.class);//指针的位数

Pointer p1 = new Memory(n * size);

p1.setPointer(0,Pointer0);

p1.setPointer(size,Pointer1);

p1.setPointer(size *2,Pointer2);

........

最后将p1传给c++即可。test1(p1,n);

相关文章

网友评论

      本文标题:Jna send pointer pointer to c++

      本文链接:https://www.haomeiwen.com/subject/rcfjkqtx.html