This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C and zero-sized arrays - what is the standard?
- From: Alexandre Courbot <Alexandre dot Courbot at lifl dot fr>
- To: "Bansidhar Arvind Deshpande - CTD, Chennai." <bansidhara at ctd dot hcltech dot com>, gcc-help at gcc dot gnu dot org
- Date: Thu, 18 Sep 2003 15:28:03 +0200
- Subject: Re: C and zero-sized arrays - what is the standard?
- References: <8DFBF35EE709D346B80B28E517B9024242D299@HARITHA.ctd.hcltech.com>
> This is for my knowlege in which kind
> of situations you make use of these
> type of structure definitions.
We are using this to store the virtual methods table that belongs to classes
meta-data in an object-oriented operating system. Every class is defined by
the same structure (CardClass), but they each class have different methods
and therefore the number of methods is not fixed (but known statically).
Using a pointer that we would allocate is not an option. First, because we are
in the kernel-space of the operating system, and second, because this
operating system is designed for very small and limited embedded systems
(typically smartcards). By declaring a variable-length table of virtual
methods we are sure that the vtable will be located right with the rest of
the structure (and not allocated god-knows-where). This makes it possible to
write smaller, more efficient code and saves us a pointer to the vtable. And
yes, 4 bytes are worth saving on a smartcard. ;)
Alex.