News for hackers. Stuff that matters.
Re:How Structs Really Work in C by rhdoenges on Sunday October 16, 2011 @01:49AM (#3116647)
Wouldn't the zero-length array potentially run into other memory?
Re:How Structs Really Work in C by notaddicted on Sunday October 16, 2011 @01:56AM (#3116664)
It is only fit to be used for heap allocation, you allocate the size that you need (i.e. malloc( sizeof(struct video_file2) + ARRAY_SIZE) ). It wouldn't work as a local variable.

edit: I suppose one could use for globals or on the stack by casting a byte array ... I would find that to be unspeakably ugly but I don't write much C.

Re:How Structs Really Work in C by rhdoenges on Sunday October 16, 2011 @11:29PM (#3119059)
ah, that's clever.
Re:How Structs Really Work in C by wollw on Sunday October 16, 2011 @02:18AM (#3116697)
That's why the usage changes to a struct pointer at that point. The struct pointer just maps parts of an existing data structure (like a video file) to its labels.
Re:How Structs Really Work in C by munin on Sunday October 16, 2011 @02:08AM (#3116681)
zero-length arrays, FYI, are not a C thing, they are a GCC thing: http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

C99 has its own "zero sized array" thing but it is a different syntax.