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

Static loop unrolling fails if loop body contains a struct #19

Open
msprotz opened this issue Jun 3, 2024 · 0 comments
Open

Static loop unrolling fails if loop body contains a struct #19

msprotz opened this issue Jun 3, 2024 · 0 comments

Comments

@msprotz
Copy link
Contributor

msprotz commented Jun 3, 2024

See commit fcc0213 which works around the issue.

Basically, if a struct is used in the loop body, then it generates a compound literal that contains a comma, and then the preprocessor thinks that the macro KRML_MAYBE_UNROLL(..., <>) receives too many arguments.

From https://stackoverflow.com/questions/13842468/comma-in-c-c-macro#19841470, which is moderately useful, two solutions are:

  • #define LOOP_BODY(...) __VA_ARGS__ and then have krml emit KRML_MAYBE_UNROLL(..., LOOP_BODY(...))
  • #define COMMA , and then have krml print at the last minute using COMMA instead of ,

The former seems easier to implement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant