如何使用swig将unsigned int引用从python传递到c++

how to pass unsigned int reference to from python to C++ using swig?

本文关键字:python c++ 引用 swig 何使用 unsigned int      更新时间:2023-10-16

我正在使用swig,它正在包装我的一个c++函数:

get(unsigned int a, unsigned int &b);

但是我没有从python调用这个函数,我得到的错误是TypeError,它应该是unsigned into &

如何从python调用这个函数?我应该在。I文件中添加一些特殊的东西吗?

是的,你应该添加typemaps。

<标题>例子:
  • 出口。我:
    %module my_mod

    输出{unsigned int&};//你输出的映射
    %包括"export.h"

  • export.h
    Void get(unsigned int a, unsigned int;

    b);
  • 测试
    print (my_mod.get (10))