This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Traditional C chokes on struct/union initialization in new cpplex.c


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]