Greg wrote:
> How does one write portable code in C to do this?
>
> If it's possible to write portably in C, then there
> must be a way to have Cython generate that portable
> C from some portable representation in Cython source.

The problem (which is now solved) arises because Cython ctypedefs are not
required to be exact, only approximate. When writing C code, your typedefs
are exact and you can always know (at least in principle) the exact type
you are dealing with.

So if you have something like this:

#ifdef A
typedef short foo
#else
typedef int foo
#endif

...then you can always throw in "#define FOO_LETTER 'h'" or "#define
FOO_LETTER 'i'" inside those #ifdefs. However, if it says this in Cython:

ctypedef int foo

then you don't "really" know the exact type of foo (and this feature will
be relied on for numpy.pxd to provide "int16", "int64" etc., and I
wouldn't like to remove it and thus require duplication of all such
#ifdefs in the pxd files).

Dag Sverre

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

Reply via email to