【问题标题】:Call function with reference参考调用函数
【发布时间】:2014-01-19 11:03:06
【问题描述】:

我正在尝试调用以下c++ 函数:

uint32_t FunctionName(uint32_t *arg1,uint32_t *arg2,uint32_t *arg3)

但我找不到将其映射到 Javacpp 的方法。

如何将指针引用传递给函数,之后如何从传递的指针中检索更改的值?

【问题讨论】:

    标签: java javacpp


    【解决方案1】:

    这样的东西应该可以正常工作:

    import com.googlecode.javacpp.*;
    import com.googlecode.javacpp.annotation.*;
    
    @Platform(include="lib.h", link="lib")
    public class Lib {
        static { Loader.load(); }
    
        public static native int FunctionName(@Cast("uint32_t*") int[] arg1,
                                              @Cast("uint32_t*") int[] arg2,
                                              @Cast("uint32_t*") int[] arg3);
        public static void main(String[] args) {
            int[] arg1 = new int[SIZE1], arg2 = new int[SIZE2], arg3 = new int[SIZE3];
            int ret = FunctionName(arg1, arg2, arg3);
            // do what you need to do with the arguments
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多