I'll throw my two cents here.
Firstly, the solution suggested in other answers talking about using an external typedef is not just a workaround, it is how Cython docs says that such things should be done. See the relevant section . Quote: "If the header file uses typedef names such as word to refer to platform-specific varieties of numeric types, you will need the appropriate ctypedef operator, but you do not need to match the type exactly, just use something suitable for the generic type (int, float etc.). For example, ctypedef int word will work fine, regardless of the actual size of the word (if the header file correctly defines it). Converting to and from Python types, if any, will also be for this new type. "
In addition, there is no need to create a header file with a typedef for a type that you have already included somewhere else along the way. Just do it
cdef extern from *: ctypedef int int128 "__int128_t"
Or, if you want to keep the name in Cython the same as in C,
cdef extern from *: ctypedef int __int128_t
Here is a test demonstrating that this works. If 128-bit arithmetic works, a > 1 , and a is represented as a 64-bit integer, the first function will print the same number again. If this is not the case, the integer overflow should make it print 0. The second function shows what happens if 64-bit arithmetic is used.
Cython file
In Python, after importing both functions, myfunc(12321) prints the correct value, and myfunc_bad(12321) prints 0.
Ianh
source share