日期:2014-05-16  浏览次数:20796 次

lex and yacc编译错误,gcc: compilation of header file requested
我用的编译命令:
yacc -d ctops.y
lex ctops.l
gcc y.tab.c lex.yy.c y.tab.h -o ctops
出现的错误:
gcc: compilation of header file requested

lex部分:
%{
#include "y.tab.h"
void stocke_commentaire();
char contenu[100];

int count;

%}
yacc部分:
%{
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include"structeurs.h"
FILE* yyin;
FILE* yyout;
extern noeudType* noeud_premiere;
extern char contenu[100];
extern int count;
noeudType* creer_noeud_reel (float value);

noeudType* creer_noeud_operateur (int numop,...);

noeudType* creer_noeud_identificateur(char* valuer);

noeudType* creer_noeud_definir (noeudType* noeud1,noeudType* noeud2);

int transformerCtoPostScript(noeudType* noeud,FILE* file);

noeudType* creer_noeud_commentaire(char* valeur);

void yyerror(char *s);

int yylex(void);

%}

------解决方案--------------------
gcc y.tab.c lex.yy.c y.tab.h -o ctops
改为
gcc y.tab.c lex.yy.c -o ctops