Re: Why do gcc support empty struct extension for?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-10-17 at 00:28 +0800, tiande wrote:
> Thank you for your further comment, especially on the standard size of pointer.
> 
> So the pointer of the empty struct definition always has a standard
> size just like any other pointer type, we can use this pointer to
> refer to a "complete struct definition" known only by private module.

Yes.  When the original C90 standard came out, there were several
implementations of C on machines that had different sizes or internal
formats of pointers.

For the early part of the standard process, I was representing the Data
General corporation whose initial machine was a 16-bit machine that only
had word pointers, and later added byte pointers by shifting the word
pointer left by one bit (the word pointer format used the top bit for an
indirection bit).  On a DG machine, structure pointers were always word
pointers, even if the only items in a structure were bytes due to the
requirement of supporting pointers to unknown structures.

> We still need the empty struct definition to tell the compiler about
> the "hidden/private" content of such struct use in current module.

My reading of the grammar in section 6.7.2.1 of the ISO C99 standard is
that it is not standards compliant for GCC to accept struct foo {},
since struct-declaration-list must contain at least one
struct-declaration, and struct-declaration must contain at least one
declarator.  GCC does not seem to warn about this.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux