This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Document empty structures
- From: Geoffrey Keating <gkeating at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 11 Apr 2003 18:38:33 -0700 (PDT)
- Subject: Document empty structures
This adds documentation of GCC's empty structure extension.
Tested with 'make info'. I'll apply to both HEAD and 3.3.
--
- Geoffrey Keating <geoffk at apple dot com>
===File ~/patches/gcc-emptystructdoc.patch==================
2003-04-11 Geoffrey Keating <geoffk at apple dot com>
* doc/extend.texi (Empty Structures): New.
Index: doc/extend.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/extend.texi,v
retrieving revision 1.128
diff -u -p -u -p -r1.128 extend.texi
--- doc/extend.texi 7 Apr 2003 07:31:47 -0000 1.128
+++ doc/extend.texi 12 Apr 2003 01:37:45 -0000
@@ -436,6 +436,7 @@ extensions, accepted by GCC in C89 mode
* Hex Floats:: Hexadecimal floating-point constants.
* Zero Length:: Zero-length arrays.
* Variable Length:: Arrays whose length is computed at run time.
+* Empty Structures:: Structures with no members.
* Variadic Macros:: Macros with a variable number of arguments.
* Escaped Newlines:: Slightly looser rules for escaped newlines.
* Multi-line Strings:: String literals with embedded newlines.
@@ -1357,6 +1358,21 @@ struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @}
struct bar c = @{ @{ 1, @{ @} @} @}; // @r{Valid.}
struct foo d[1] = @{ @{ 1 @{ 2, 3, 4 @} @} @}; // @r{Invalid.}
@end example
+
+ at node Empty Structures
+ at section Structures With No Members
+ at cindex empty structures
+ at cindex zero-size structures
+
+GCC permits a C structure to have no members:
+
+ at example
+struct empty @{
+ at };
+ at end example
+
+The structure will have size zero. In C++, empty structures are part
+of the language, and the language standard says they have size 1.
@node Variable Length
@section Arrays of Variable Length
============================================================