help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: header file guards conflict


From: Akim Demaille
Subject: Re: header file guards conflict
Date: Mon, 21 May 2012 11:34:14 +0200

Le 16 mai 2012 à 16:51, Wei Song a écrit :

> Hi,

Hi!

> Just have used Bison for several months.
> 
> I have two bison parsers in one project and for some reasons the header files 
> of both parsers are included in one cpp code.
> Different namespace names are used, therefore, these two parsers do not 
> conflict.
> However, there is an unexpected problem.
> The header guard in location.hh is BISON_LOCATION_HH, the same in both 
> location.hh files (not only this file).
> As result, I need to do something like the following in my code:
> 
> #include "parser1.hh"
> 
> // undefine all the conflicted header guards
> #undef PARSER_HEADER_H
> #undef BISON_LOCATION_HH
> #undef BISON_POSITION_HH
> 
> #include "parser2.hh"
> 
> Is there a better way to do it?

This is indeed a problem.  I'm sure what the best way to
address this is.  In addition, in some cases, creating the
files location.hh, stack.hh etc. is more troublesome than
useful.

Also, some people would like to be able to rename the location.hh
file.

Currently we use BISON_LOCATION_HH (it is open-coded).  One
first idea would be to use the output file name, so if
for instance you passed "-o lang1/parser.cc", the header would
be BISON_LANG1_LOCATION_HH.  Would that suffice in your case?
Maybe BISON_ is not needed actually.

Maybe we should also include the given name-prefix?  So
this would typically be YY_LANG1_LOCATION_HH.

Don't you have the exact same problem with your parser
header file?  Currently it is PARSER_HEADER_H…  Using
name-prefix + full output name (with directory) that
would be YY_LANG1_PARSER_HH.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]