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

James Colannino james at colannino.org
Sat Jun 19 19:20:41 PDT 2004


Christopher Smith wrote:
> 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.

Ah, I see.  I was wondering if there was just some type of bug in my 
programming that I couldn't find or if it was actually an issue with the 
compiler itself.  I'm glad it wasn't me :-P  I'll probably just go ahead 
and use #define for this particular circumstance.

James
-- 
My blog: http://www.crazydrclaw.com/
My homepage: http://james.colannino.org/

"There are no uninteresting things; only uninterested people." --G.K. 
Chesterton



More information about the OCLUG-devel mailing list