Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swig python - c++ how to use type int8_t

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.

like image 676
Stefano Avatar asked Jan 17 '12 15:01

Stefano


1 Answers

In your SWIG interface file use:

%include "stdint.i"

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

like image 164
Flexo Avatar answered Nov 06 '22 06:11

Flexo