[Cython] A bug when declare array.

yi huang yi.codeplayer at gmail.com
Tue Aug 27 10:19:03 CEST 2013


I just chooses a large enough buffer size, there is not much to waste anyway.

On Tue, Aug 27, 2013 at 3:43 PM, Sturla Molden <sturla at molden.no> wrote:
>
>
>
> Den 22. aug. 2013 kl. 06:01 skrev Robert Bradshaw <robertwb at gmail.com>:
>
>> On Sat, Aug 17, 2013 at 3:31 AM, yi huang <yi.codeplayer at gmail.com> wrote:
>>> I use cython 0.19.1, when compile following code:
>>>
>>> cdef void some_function():
>>>    cdef char buf[sizeof(long)*8/3+6]
>>>
>>> Got error message:
>>>
>>> Error compiling Cython file:
>>> ------------------------------------------------------------
>>> ...
>>> cdef void some_function():
>>>    cdef char buf[sizeof(long)*8/3+6]
>>>                ^
>>> ------------------------------------------------------------
>>>
>>> /tmp/test.pyx:2:17: Variable type 'char []' is incomplete
>>
>> That's an interesting one... it's a compile time value at C
>> compilation time, but not a Cython compilation time. I don't have a
>> quick fix.
>>
>
> That's an annoying error. I have never encountered it, but still it annoys me :-(
>
> A quick fix is to use alloca instead
>
>      cdef char *buf = alloca(sizeof(long)*8/3+6)
>
> but beware that sizeof(buf) will be different.
>
> Sturla
>
>
>
>
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel



-- 
http://yi-programmer.com/


More information about the cython-devel mailing list