Swig Python-C ++如何使用int8_t类型 [英] Swig python - c++ how to use type int8_t
问题描述
我有一个C函数,该函数将8位整数作为参数
I have a C function that takes as paramenter an 8 bit integer
int8_t foo( int8_t x );
我想使用swig接口从我的python代码中调用此函数,但int8_t类型不存在在python中。
为了具有这种类型,存在一个称为numpy的python模块。
即使使用此方法,我也无法进行2的通信。
I would like to call this function from my python code using a swig interface but int8_t type do not exists in python. In order to have this kind of types exists a python module called numpy. Even using this yet I do not manage to make the 2 comunicating.
您知道在SWIG接口中是否有定义此类的方法为了能够从python使用它?
Do you know if there is any way of defining such a type in the SWIG interfacve in order to be able to use it from python??
int8_t只是一个示例...我必须对从8到64的有符号/无符号进行相同的操作位
int8_t is just an example... i have to do the same for signed/unsigned from 8 up to 64 bits
在此先感谢
S。
Thanks in advance, S.
推荐答案
在您的SWIG界面文件中使用:
In your SWIG interface file use:
%include "stdint.i"
之前,您首先使用 uint8_t
。然后,SWIG将为您应用适当的类型映射。
before you first use uint8_t
. SWIG will then apply an appropriate typemap for you.
这篇关于Swig Python-C ++如何使用int8_t类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!