博客
关于我
jna 调用c++ dll 返回复杂结构体
阅读量:305 次
发布时间:2019-03-03

本文共 605 字,大约阅读时间需要 2 分钟。

经过折腾,确定,在java中定义同样的结构体,如c++中

struct Location {	int nums;	int arr[10];//数组的传递。不能用int *,因为jna的IntByReference.getValue()只能返回一个值};

在java中的定义为

public static class Location extends Structure{            public int nums;            public int[] arr=new int[10];            @Override protected List getFieldOrder() {                return Arrays.asList(new String[]{"nums","arr"});            }        }

dll中函数定义为、

DLL_EXPORT void get_location_message(double,double,Location &);

返回值用引用类型

java中直接调用

CLibrary.Location l=new CLibrary.Location();CLibrary.INSTANCE.get_location_message(lat,lon,l);

这样返回的Location就没有问题了。

转载地址:http://rtim.baihongyu.com/

你可能感兴趣的文章
MySQL一个表A中多个字段关联了表B的ID,如何关联查询?
查看>>
MYSQL一直显示正在启动
查看>>
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL不会性能调优?看看这份清华架构师编写的MySQL性能优化手册吧
查看>>