aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2000-07-07 14:29:03 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2000-07-07 14:29:03 +0000
commit7de9cc38c319240807a7942d7cbd1b0c1933a766 (patch)
treed9356d2f4ae40764d3e91f80189ed3959eb51f8e /gcc
parentd199cba40a43c0a7f6487ebbbe00899b15b45380 (diff)
downloadgcc-7de9cc38c319240807a7942d7cbd1b0c1933a766.zip
gcc-7de9cc38c319240807a7942d7cbd1b0c1933a766.tar.gz
gcc-7de9cc38c319240807a7942d7cbd1b0c1933a766.tar.bz2
system.h (UNION_INIT_ZERO): New macro for initializing union members in structs.
* system.h (UNION_INIT_ZERO): New macro for initializing union members in structs. * cpplex.c (placemarker_token, eof_token): Use UNION_INIT_ZERO. From-SVN: r34904
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/cpplex.c4
-rw-r--r--gcc/system.h10
3 files changed, 19 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e53d1e5..bac2fdc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2000-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * system.h (UNION_INIT_ZERO): New macro for initializing union
+ members in structs.
+
+ * cpplex.c (placemarker_token, eof_token): Use UNION_INIT_ZERO.
+
2000-07-07 Neil Booth <NeilB@earthling.net>
* cpp.texi: Update.
diff --git a/gcc/cpplex.c b/gcc/cpplex.c
index 5f1707a..24e4712 100644
--- a/gcc/cpplex.c
+++ b/gcc/cpplex.c
@@ -1935,8 +1935,8 @@ spell_token (pfile, token, buffer)
/* Macro expansion algorithm. TODO. */
-static const cpp_token placemarker_token = {0, 0, CPP_PLACEMARKER, 0, {0}};
-static const cpp_token eof_token = {0, 0, CPP_EOF, 0, {0}};
+static const cpp_token placemarker_token = {0, 0, CPP_PLACEMARKER, 0 UNION_INIT_ZERO};
+static const cpp_token eof_token = {0, 0, CPP_EOF, 0 UNION_INIT_ZERO};
#define IS_ARG_CONTEXT(c) ((c)->flags & CONTEXT_ARG)
#define CURRENT_CONTEXT(pfile) ((pfile)->contexts + (pfile)->cur_context)
diff --git a/gcc/system.h b/gcc/system.h
index ab2cfa7..d5fb4d2 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -600,4 +600,14 @@ extern void abort PARAMS ((void));
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
+/* Traditional C cannot initialize union members of structs. Provide
+ a macro which expands appropriately to handle it. This only works
+ if you intend to initalize the union member to zero since it relies
+ on default initialization to zero in the traditional C case. */
+#ifdef __STDC__
+#define UNION_INIT_ZERO , {0}
+#else
+#define UNION_INIT_ZERO
+#endif
+
#endif /* __GCC_SYSTEM_H__ */