[OCLUG-devel] declaring structures outside of main()

Christopher Smith x at xman.org
Sat Jun 19 19:00:39 PDT 2004


On Sat, 2004-06-19 at 18:19, James Colannino wrote:
> This is really weird and I was hoping that someone could shed some light 
> on this.

In general, variable sized arrays are funky business in C. C99 addresses
this, but it's not well implemented in a lot of compilers. In gcc's
case, I know it can use alloca to make variable sized arrays when you
are inside a block (function or otherwise), but when you have a global,
that won't work.

My advice: allocate the array with malloc and/or use #define for your
constant.

-- 
Christopher Smith <x at xman.org>


More information about the OCLUG-devel mailing list