博客
关于我
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之IN 和 Exists 用法
查看>>
MYSQL之REPLACE INTO和INSERT … ON DUPLICATE KEY UPDATE用法
查看>>
MySQL之SQL语句优化步骤
查看>>
MYSQL之union和order by分析([Err] 1221 - Incorrect usage of UNION and ORDER BY)
查看>>
Mysql之主从复制
查看>>
MySQL之函数
查看>>
mysql之分组查询GROUP BY,HAVING
查看>>