[Python-Dev] ssize_t branch merged

Travis E. Oliphant oliphant.travis at ieee.org
Sat Feb 18 05:17:00 CET 2006


Tim Peters wrote:
> [Travis Oliphant]
> 
>>Maybe I have the wrong version of code.  In my pyport.h (checked out
>>from svn trunk) I have.
>>
>>#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
>>
>>What is size_t?
> 
> 
> size_t is an unsigned integral type defined by, required by, and used
> all over the place in standard C.  What exactly is the compiler
> message you get, and exactly which compiler are you using (note that
> nobody else is having problems with this, so there's something unique
> in your setup)?

I'm very sorry for my silliness.  I do see the problem I was having now. 
   Thank you for helping me out.  I was assuming that PY_SSIZE_T_MAX 
could be used in a  pre-processor statement like LONG_MAX and INT_MAX.

In other words

#if PY_SSIZE_T_MAX != INT_MAX

This was giving me errors and I tried to understand the #define 
statement as an arithmetic operation (not a type-casting one).  I did 
know about size_t but thought it strange that 1 was being subtracted 
from it.

I would have written this as (size_t)(-1) to avoid that confusion.  I do 
apologize for my error.  Thank you for taking the time to explain it.

I still think that PY_SSIZE_T_MAX ought to be usable in a pre-processor 
statement, but it's a nit.

Best,

-Travis



> 
> No.  (size_t)-1 casts -1 to the unsigned integral type size_t,

That's what I was missing I saw this as subtraction not type-casting. 
My mistake

-Travis



More information about the Python-Dev mailing list