Yacc and Lex inclusion confusion
- by thejohnmeister
I am wondering how to correctly compile a program with a Makefile that has calls to yyparse in it?
This is what I do:
I have a Makefile that compiles all my regular files and they have no connections to y.tab.c or lex.yy.c (Am I supposed to have them?)
I do this on top of my code:
#include "y.tab.c"
#include "lex.yy.c"
#include "y.tab.h"
This is what happens when I try to make the program:
When I just type in "make", it gives me many warnings. Some of the examples are shown below.
In function yywrap':
/src/parser.y:12: multiple definition ofyywrap'
server.o
:/src/parser.y:12: first defined here
utils.o:
In function yyparse':
/src/y.tab.c:1175: multiple definition ofyyparse'
server.o:/src/y.tab.c:1175: first defined here
utils.o
I get many different errors referring to different yy_* files. I have compiled successfully with multiple calls to yyparse in the past, but this time seems to be different. It seems an awful lot like an inclusion problem somewhere but I can't tell what it is. All my header files have ifndef conditions, as well.
Thanks for your help!