20

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.

Stefano
  • 3,981
  • 8
  • 36
  • 66

1 Answers1

37

In your SWIG interface file use:

%include "stdint.i"

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

AFoglia
  • 7,968
  • 3
  • 35
  • 51
Flexo
  • 87,323
  • 22
  • 191
  • 272