Swig python - c++ how to use type int8_t

邮差的信 提交于 2019-12-05 13:51:26

问题


I have a C function that takes as paramenter an 8 bit integer

int8_t foo( int8_t x );

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.

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 is just an example... i have to do the same for signed/unsigned from 8 up to 64 bits

Thanks in advance, S.


回答1:


In your SWIG interface file use:

%include "stdint.i"

before you first use uint8_t. SWIG will then apply an appropriate typemap for you.



来源:https://stackoverflow.com/questions/8897294/swig-python-c-how-to-use-type-int8-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!