Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#126 redefinition of class FlexLexer

2.5.35
open
nobody
C++ (13)
5
2011-03-28
2011-03-28
Claude_B
No

Using flex 2.5.35 with Bison, codes in C++.

When "FlexLexer.h" is included several times, a compile error occurs "redefinition of class FlexLexer". Double inclusion will happen when flex is associated with a parser in Bison because the parser code has to include FlexLexer.h, this inclusion appears in Bison-generated "parser.tab.hh" which has to be included in the flex code.

The solution is to insert the line "#undef FlexLexer" just before the class FlexLexer definition in FlexLexer.h.

Discussion

  • Will Estes
    Will Estes
    2012-08-08

    I think the proposed solution would conflict with the documented way of including multiple flexlexer's in a single program. Is there an instance you can provide where the documented solution fails to work?