博客
关于我
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丢失更新问题
查看>>
MySQL两千万数据优化&迁移
查看>>
MySql中 delimiter 详解
查看>>
MYSQL中 find_in_set() 函数用法详解
查看>>