You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a bug in flex (master) for C++ scanner generation at in src/main.c at line 1679:
if (!do_yywrap) {
outn("\nint yyFlexLexer::yywrap() { return 1; }");
}
The definition of yyFlexLexer::yywrap() appears in both the header and implementation file. Prefixing with inline solves the problem, but maybe a better solution would be to only output to the implementation file?
The text was updated successfully, but these errors were encountered:
#include"ScannerX.hpp"intmain() {
FlexLexer *lex = new yyFlexLexer;
lex->yylex();
}
$ flex lexer_bug.l
$ g++ ScannerX.cpp main.cpp
/usr/bin/ld: /tmp/cc2Aqsft.o: in function `yyFlexLexer::yywrap()':
main.cpp:(.text+0x0): multiple definition of `yyFlexLexer::yywrap()'; /tmp/ccmi47fP.o:ScannerX.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Two solutions are to #include <FlexLexer.h> instead or the fix to src/main.c above. I still believe the code is broken however, as it generates a header which cannot safely be referenced.
There seems to be a bug in flex (master) for C++ scanner generation at in src/main.c at line 1679:
The definition of yyFlexLexer::yywrap() appears in both the header and implementation file. Prefixing with
inline
solves the problem, but maybe a better solution would be to only output to the implementation file?The text was updated successfully, but these errors were encountered: