01-22 2132人
C: typedef struct Example3Struct { int val; } Example3Struct; ... void example3_sendStruct(const Example3Struct* sval) { printf("(C) %d\n", sval->val); } java: public interface CLibrary extends Library { //java bean 继承Structure public static class Example3Struct extends Structure { public static class ByReference extends Example3Struct implements Structure.ByReference {} public int val; } ... //调用动态库,传入结构体 public void example3_sendStruct(Example3Struct.ByReference sval); } ... CLibrary clib = (CLibrary)Native.loadLibrary("testlib", CLibrary.class); ... CLibrary.Example3Struct.ByReference e3ref = new CLibrary.Example3Struct.ByReference(); e3ref.val = 7; clib.example3_sendStruct(e3ref); //www.sitcoder.com