Correct way to interact with arrays using SWIG

后端 未结 2 426
刺人心
刺人心 2020-12-31 22:52

I\'m a bit lost with typemaps in swig and how to use arrays. I have prepared a working example that uses arrays between java and c using swig, but i don\'t know if it is the

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-31 23:01

    It's well documented here: http://swig.org/Doc3.0/SWIGDocumentation.html#Java_binary_char

    The interface file below will generate byte[] method in java:

    %apply (char *STRING, size_t LENGTH) { (const char data[], size_t len) }
    %inline %{
    void binaryChar1(const char data[], size_t len) {
      printf("len: %d data: ", len);
      for (size_t i=0; i

提交回复
热议问题