Jason Evans wrote:
> Michael Abshoff wrote:
>> Lisandro Dalcin wrote:
>>> Cython treats sizeof() as if it returns 'int', but IMHO it should be 
>>> 'size_t'.
>> Well, you might be technically correct since that is what the C standard 
>> asks for, but according to various literature, i.e. for example
>>
>> http://publications.gbdirect.co.uk/c_book/chapter5/sizeof_and_malloc.html
>>
>> "The sizeof operator returns the size in bytes of its operand. Whether 
>> the result of sizeof is unsigned int or unsigned long is implementation 
>> defined—which is why the declaration of malloc above ducked the issue by 
>> omitting any parameter information; "
> 
> That book appears to have been published in 1991...

Yeah, it has been a while, but then Python requires a C89 compiler :)

> Personally, I've found the lack of native size_t knowledge in Cython to 
> be a major pain.  In practice though, the following is sufficient for 
> every modern system I know of, with the likely exception of Windows:
> 
>      cdef extern from "sys/types.h":
>          ctypedef unsigned long size_t


Well, make it unsigned long long on 64 bit Windows and it ought to work 
nearly everywhere. I am not aware of any LLP64 bit OS that Cython 
supports besides 64 bit Windows. Obviously there is no sys/types.h on 
Windows, but that is a different story :)

> Jason

Cheers,

Michael

> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
> 

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to