Nothing Special   »   [go: up one dir, main page]

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

Don't use C99 syntax in for loop for smoother make #274

Closed
7890 opened this issue Dec 6, 2019 · 1 comment
Closed

Don't use C99 syntax in for loop for smoother make #274

7890 opened this issue Dec 6, 2019 · 1 comment
Assignees
Milestone

Comments

@7890
Copy link
7890 commented Dec 6, 2019
diff --git a/source/src/BNFC/Backend/C/CFtoFlexC.hs b/source/src/BNFC/Backend/C/CFtoFlexC.hs
index 5f56765..85f7cc1 100644
--- a/source/src/BNFC/Backend/C/CFtoFlexC.hs
+++ b/source/src/BNFC/Backend/C/CFtoFlexC.hs
@@ -98,7 +98,8 @@ prelude name = unlines
    "{",
    "  loc->first_line = loc->last_line;",
    "  loc->first_column = loc->last_column;",
-   "  for (int i = 0; text[i] != '\\0'; ++i) {",
+   "  int i;",
+   "  for (i = 0; text[i] != '\\0'; ++i) {",
    "      if (text[i] == '\\n') {",
    "          ++loc->last_line;",
    "          loc->last_column = 0; ",

This helped to make without errors.

@andreasabel
Copy link
Member
andreasabel commented Dec 6, 2019

Sure, approved. (I wasn't aware that this form is not standard. On the other hand, I also did not write this code and am not intimately familiar with C in the first place.)

Thanks for reporting! (A PR would have given bonus points.)

@andreasabel andreasabel added this to the 2.8.4 milestone Dec 6, 2019
@andreasabel andreasabel self-assigned this Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants