[Cython] Specification proposal for extern ctypedef exactness

Robert Bradshaw robertwb at math.washington.edu
Fri Jul 25 17:52:24 CEST 2008


On Jul 25, 2008, at 8:25 AM, Dag Sverre Seljebotn wrote:

> I've been touching upon this before, I'm now wondering whether we  
> can make
> an exact documented specification of how extern ctypedefs can work (if
> there is already then I apologize..).
>
> Proposal:
>
> - It is *not* necesarry that the size (long/short or float/double/long
> double) matches with the real type in C
> - However it *is* required that "unsigned" vs "signed" is correctly
> declared, and that "int" vs. "float" is correctly declared.  
> (Failing to do
> this leads to undefined behaviour for now, but a module-loading-time
> exception could be arranged for.)
>
> Furthermore, it is recommended (just to have a guideline somewhere) to
> only use the types "int", "unsigned int" and "float" in extern  
> ctypedefs.
>
> (The new thing here is relying on unsigned vs. signed, which I want  
> to use
> for dropping support for negative buffer indexing in situations where
> there can be no negative indices (I'm sure gcc could do it for me  
> but it
> helps not confusing the users too)).

Yes, I believe this is already the case. One may be able to get away  
with wrongly declaring unsigned vs. signed, but there are no promises  
as to the correctness if one does that.

- Robert




More information about the Cython-dev mailing list