我有一个以 8 位整数为参数的 C 函数
int8_t foo( int8_t x );
我想使用 swig 接口(interface)从我的 python 代码中调用此函数,但 python 中不存在 int8_t 类型。 为了拥有这种类型,存在一个名为 numpy 的 python 模块。 即使使用它,我也无法进行 2 通信。
您知道是否有任何方法可以在 SWIG 接口(interface)中定义这种类型以便能够从 python 中使用它??
int8_t 只是一个例子......我必须对从 8 位到 64 位的有符号/无符号执行相同的操作
提前致谢, S.
最佳答案
在您的 SWIG 接口(interface)文件中使用:
%include "stdint.i"
之前你首先使用uint8_t
。然后 SWIG 将为您应用适当的类型映射。
关于c++ - Swig python - c++ 如何使用 int8_t 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897294/