c++ - Bison and doesn't name a type error -


i have following files:

cp.h

#ifndef cp_h_ #define cp_h_  class cp { public:         enum cardinalite {vide = '\0', ptint = '?', ast = '*', plus = '+'};          cp(cardinalite mycard);         virtual ~cp(); private:         cardinalite card; };  #endif /* cp_h_ */ 

and dtd.y

%{  using namespace std; #include <cstring> #include <cstdio> #include <cstdlib> #include "analyseurdtd/dtddocument.h" #include "analyseurdtd/cp.h"  void yyerror(char *msg); int yywrap(void); int yylex(void);  dtddocument * doc = new dtddocument(); %}  %union {          char *s;         dtdelement * dtdelt;         cp *cpt;         cp::cardinalite card; } 

and following strange error:

analyseurdtd/dtd.y:20:2: error: ‘cp’ not name type analyseurdtd/dtd.y:21:2: error: ‘cp’ not name type 

the stange thing if put cp *cpt; after dtddocument * doc = new dtddocument(); have no error :/

include header in scanner file before include *.tab.h

// scanner.l file  %{ #include "myheader.h"  #include "yacc.tab.h"  // other c/c++ code  %}  // helper definitions  %%  // scanner rules   %% 

%union defined in yacc.tab.h when compile need make sure compiler sees new type definitions before process yacc.tab.h


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -