te07@edrc.cmu.edu (Thomas Epperly) (07/26/89)
I have found a problem using yacc and cc on the DECstation 3100. I don't know enough to say which is wrong, but I know that they don't work together like they should. I define the following union in my yacc input file: excerpt from yacc input file. %union { double rvalue; long ivalue; struct variable *vptr; struct gl_list_t *elist; } The C program that yacc produces include these parts: /* some deleted lines */ # line 88 "gram.y" typedef union { double rvalue; long ivalue; struct variable *vptr; struct gl_list_t *elist; } YYSTYPE; /* some more deleted lines */ #ifndef YYSTYPE #define YYSTYPE int /* It redefines YYSTYPE here */ #endif YYSTYPE yylval, yyval; /* some more lines */ As commented above, the #ifndef YYSTYPE executes the #define YYSTYPE int. Therefore, I get errors everytime I use yylval.{anything} E.g. ccom: Warning: gram.y, line 270: struct/union or struct/union pointer required gl_append_ptr(yyval.elist,g_expr_ptr); ---------------------------^ I have a call in with DEC, but the right people haven't called back yet. The work around that I am using is to include the following in my Makefile. .y.c: $(YACC) $(YFLAGS) $< sed -e "/#ifndef YYSTYPE/,/#endif/d" < y.tab.c > y.new.c rm -f y.tab.c mv y.new.c $@ Tom Epperly