[Cython] C -- Variable-sized array on stack?

Dag Sverre Seljebotn dagss at student.matnat.uio.no
Thu Apr 30 21:08:04 CEST 2009


Will I get away with code like this in Cython?

void foo(int n) {
   int stack[n];
   ...
}

I.e. what C language level are we targeting exactly? Also, does the 
above cause a proper stack allocation?

I get

test.c:15: warning: ISO C90 forbids variable-size array ‘arr’

with -ansi -pedantic but otherwise gcc seems happy enough.

(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.)

-- 
Dag Sverre


More information about the Cython-dev mailing list