Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC error 2229 #202

Closed
Albertweiku opened this issue Mar 26, 2024 · 3 comments
Closed

MSVC error 2229 #202

Albertweiku opened this issue Mar 26, 2024 · 3 comments
Labels
invalid This doesn't seem right question A technical question that has or needs clarification

Comments

@Albertweiku
Copy link

Generation method:

  • Use re-flex 4.1;
    The build option uses --flex --header-file -i

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

@genivia-inc
Copy link
Member

genivia-inc commented Mar 26, 2024

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.

@Albertweiku
Copy link
Author

image
image
image

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?

@genivia-inc
Copy link
Member

genivia-inc commented Mar 27, 2024

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";
      }

@genivia-inc genivia-inc added invalid This doesn't seem right question A technical question that has or needs clarification labels Mar 27, 2024
genivia-inc added a commit that referenced this issue Mar 27, 2024
- add pkg-config files reflex.pc and relfexmin.pc with updated configure and makefiles
- minor update of option -p to permit empty lexer specifications #202
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right question A technical question that has or needs clarification
Projects
None yet
Development

No branches or pull requests

2 participants