#126 redefinition of class FlexLexer

2.6.0
open
nobody
C++ (13)
5
2015-11-18
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?

     
  • Will Estes

    Will Estes - 2015-11-18
    • Group: 2.5.35 --> 2.6.0
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks