On Thu, Apr 30, 2009 at 4:08 PM, Dag Sverre Seljebotn
<[email protected]> wrote:
> Will I get away with code like this in Cython?
>
> void foo(int n) {
> int stack[n];
> ...
> }
>
I would prefer if that feature is not used in Cython code.
> I.e. what C language level are we targeting exactly?
As we currently target Py2.x, we should support C89/C90, and
variable-sized, automatic arrays, are not in C89 AFAIK.
> Also, does the
> above cause a proper stack allocation?
>
I believe is a kind of special allocation, likely not a "normal" stack
allocation (like you get when do "int stack[5]"). If the allocation
fails for any reason ("n" negative? no enough mem?) your process will
likely get signaled (SIGSEGV?).
> I get
>
> test.c:15: warning: ISO C90 forbids variable-size array ‘arr’
>
> with -ansi -pedantic but otherwise gcc seems happy enough.
>
Variable-sized, automatic arrays are a C99 feature, but GCC has
provided them as an extension for long time ago... That's the reason
you get warnings with -pedantic (which in fact is a portability
testing flag).
> (I can get away without doing this as the caller knows the size
> compile-time and can supply the needed stack in the caller function
> stack frame, but this would make the code a lot nicer.)
>
Hope my previous arguments help you to make a decision... From my
side, -1. I prefer portability over nicer generated C codes.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev