Alternative to a global VLA - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: Alternative to a global VLA (/thread-4073.html)
Alternative to a global VLA - ferum - Jul 23, 2006 07:49 AM
I have been working on my primitive game, and up till now I have been loading verteces and triangles form OBJ files into linked lists. I went to change the program to use VLAs instead, but ran into trouble. I need the VLAs to be global, as it is a glut program, but the C standard does not allow VLAs to have file scope. Is there a loophole or something I can exploit to allow me to use VLAs or is there some alternative? Will I just have to hard wire the array sizes in? What do you guys use for storing OBJ data?
Alternative to a global VLA - ThemsAllTook - Jul 23, 2006 08:51 AM
What exactly is a VLA?
Alternative to a global VLA - OneSadCookie - Jul 23, 2006 01:29 PM
I have no idea what a VLA is, but I use malloc'd memory to store OBJ data... I can't imagine anyone else does anything else.
Alternative to a global VLA - ferum - Jul 23, 2006 03:41 PM
a VLA is a Variable Length Array. For example:
So malloc is the way to go? ok thanks.
Alternative to a global VLA - socksy - Jul 24, 2006 08:10 AM
Are you sure? http://en.wikipedia.org/wiki/VLA
I fail to see the difference between your VLA which google hasn't appeared to have heard of to an array - does it say this in a textbook somewhere?
Alternative to a global VLA - ferum - Jul 24, 2006 06:44 PM
google "variable length array". Its an array whose initialization size parameter is a variable. for example:
Alternative to a global VLA - OneSadCookie - Jul 24, 2006 06:47 PM
We know what a variable-length array is, but VLA is not a common abbreviation for it.
Incidentally, variable-length arrays are not legal in C++, ObjC, or C (prior to C99). GCC allows them by default anyway, though -- how nice of it :|