This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Traditional C chokes on struct/union initialization in new cpplex.c
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: Traditional C chokes on struct/union initialization in new cpplex.c
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Wed, 5 Jul 2000 17:21:47 -0400
- Cc: zack at wolery dot cumb dot org, gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- References: <200007052059.QAA26992@caip.rutgers.edu>
On Wed, Jul 05, 2000 at 04:59:47PM -0400, Kaveh R. Ghazi wrote:
> Hi Zack,
>
> I had some trouble compiling the overhauled cpplex.c on sunos4
> using its K&R cc compiler. I get:
>
> > "../../egcs-CVS20000705/gcc/cpplex.c", line 1938: operands of = have
> > incompatible types
> > "../../egcs-CVS20000705/gcc/cpplex.c", line 1939: operands of = have
> > incompatible types
>
>
> The problem occurs on these two lines from cpplex.c:
>
> > static const cpp_token placemarker_token = {0, 0, CPP_PLACEMARKER, 0, {0}};
> > static const cpp_token eof_token = {0, 0, CPP_EOF, 0, {0}};
>
> Based on some experimentation, it appears to me that traditional C
> cannot initialize a union member of a struct. I tried getting it to
> work by playing with braces, etc., but no luck.
Yes, initializing a union by initializing the first member was an invention of
the ANSI C committee (now ISO C standard).
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482