Closed Albertweiku closed 5 months ago
OK, but do you have an example lexer input file for us to replicate the problem so we can fix it? That would help. Without a test case we can only guess, since the tool and the output generation has lots of options.
The generated header file declares the yyFlexLexer
class with yylex()
method and nothing else, no structures, no bit fields and no zero length arrays, at least not by default and not with the usual options.
So again, please provide more details when this happens.
Even if I use a near-empty lex file to generate the header file, it has an array of declared size 0.This seems to be a disallowed behavior in MSVC. Is it because there is a problem with my options?
That output is generated with option -p
. These arrays track the performance of every lexer rule. If there are no rules specified, then these arrays are empty.
This never happens with normal lexer specifications that have at least one rule. Lexer specifications that do not have rules are not useful.
Perhaps the reflex tool should just bail out with an error and not generate any code when no rules are specified.
On the other hand, just removing these empty array declarations from the output works fine too. Perhaps something to do for the next release update, it's just easy to work around by adding a guard like so in src/reflex.cpp:2399:
if (report > 0) // skip when zero: no rules specified
{
*out <<
" size_t perf_report_" << conditions[start] << "_rule[" << report << "];\n"
" size_t perf_report_" << conditions[start] << "_size[" << report << "];\n"
" float perf_report_" << conditions[start] << "_time[" << report << "];\n";
}
Generation method:
The problem is that the resulting header file contains a large number of structure or bit fields whose members contain an array of size zero, but that is not the last member. This causes errors when compiling with msvc.
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/compiler-error-c2229?view=msvc-170