In C extension .pyd, sizeof INT64 = 4?

Laurent Pointal laurent.pointal at wanadoo.fr
Thu Jun 14 13:01:41 EDT 2007


Allen wrote:

> On 6 13 ,   11 55 , "Martin v. Löwis" <mar... at v.loewis.de> wrote:
>> > I used INT64 and initialize its value from PyArg_ParseTuple.
>> > The code is PyArg_ParseTuple(args, "l", &nValue).
>> > It should be PyArg_ParseTuple(args, "L", &nValue).
>>
>> That's still incorrect. For the L format flag, use PY_LONG_LONG,
>> not your own INT64 type. More generally: always use the type
>> documented in
>>
>> http://docs.python.org/api/arg-parsing.html
>>
>> Regards,
>> Martin
> 
> PY_LONG_LONG is decleared as __int64 on windows. There is no
> difference.

IMHO. Make your code platform independant and use your compiler capacities. 

If for an 'L' argument PyArg_ParseTuple requires a PY_LONG_LONG, then give
it a PY_LONG_LONG and assign the parsed value into an INT64 after parsing.
 
You dont know if PY_LONG_LONG or INT64 wil not be defined differently in the
future, so use them where they are specified, do the assignment, and leave
the compiler warn you if anything become invalid in the futur.

My 2 cents.

A+

Laurent.




More information about the Python-list mailing list