[Cython] long long and VC6
Kirill Simonov
xi at gamma.dn.ua
Sat Jan 3 13:06:40 CET 2009
>>>> I'm using Cython 0.10.3 to build an extension module and the
>>>> generated C
>>>> file does not compile under VC6, which I use to create a Windows
>>>> binary
>>>> package for Python 2.3. The culprit is the following expression:
>>>>
>>>> PyObject *j = (likely(i >= 0) || !is_unsigned) ? PyInt_FromLong(i) :
>>>> PyLong_FromUnsignedLongLong((sizeof(unsigned long long) >
>>>> sizeof(Py_ssize_t) ? (1ULL << (sizeof(Py_ssize_t)*8)) : 0) + i);
>>>>
>>>> in the function __Pyx_GetItemInt. It looks like VC6 does not know
>>>> about
>>>> "long long". I suppose Cython should respect HAVE_LONG_LONG and use
>>>> PY_LONG_LONG macro instead of "long long".
>>> Hmm... I don't have any experience with VC6, but it looks like a bug
>>> to me. Could you file a bug report on trac? Also, do you know if
>>> PY_LONG_LONG guaranteed to be 64+ bits?
>> I can't file a bug report, got Forbidden here:
>>
>> http://trac.cython.org/cython_trac/newticket
>>
>> I don't know about PY_LONG_LONG on 64+, but long long is C99, so I
>> suppose it's a reasonably safe assumption.
>
> I am not sure what Python 2.3 does, but the standard workaround for VC 6
> is to define long long as __int64. But if PY_LONG_LONG is supported I
> would obviously recommend to use that.
Indeed you are right. After replacing "unsigned long long" with
"unsigned PY_LONG_LONG" and "1ULL" with "((unsigned PY_LONG_LONG) 1)",
it compiles under VC6.
Thanks,
Kirill.
More information about the Cython-dev
mailing list