[Pyrex] Platform dependent external declarations?

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 1 03:11:40 UTC 2007


Eric Huss wrote:

> cdef extern from "sys/types.h":
>     ctypedef unsigned int time_t
> 
> def foo(time_t x):
>     print x
> 
> will generate different code from:
> 
> cdef extern from "sys/types.h":
>     ctypedef int time_t
> 
> def foo(time_t x):
>     print x

Okay, I see what the problem is now. Different conversion
functions are used to convert to and from Python objects
depending on the signedness.

But is this really a problem in practice? Seems to me that
if the same thing is declared unsigned on some platforms
but not others, then either the values never extend into
the range where the sign matters, or it really is unsigned,
even if some platforms don't bother declaring it as such.
In either case, declaring it as unsigned to Pyrex should
work.

Does anyone have any use cases where this would fail?

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+



More information about the Pyrex mailing list