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

C backend assumes that user of header file includes stdio.h #381

Closed
enedil opened this issue Sep 15, 2021 · 3 comments · Fixed by #382
Closed

C backend assumes that user of header file includes stdio.h #381

enedil opened this issue Sep 15, 2021 · 3 comments · Fixed by #382
Assignees
Labels
C parser Issues concerning parser generating
Milestone

Comments

@enedil
Copy link
Contributor

enedil commented Sep 15, 2021

In the C backend, none of the generated headers include any header from standard library. This is wrong, as Parser.h uses FILE*, which is defined in stdio.h. Thus, stdio.h should be also included.

BNFC version that I use: 2.9.1.
OS: Fedora 34
BNFC distribution: stack

enedil added a commit to enedil/bnfc that referenced this issue Sep 15, 2021
Parser.h uses FILE*, however doesn't include stdio.h, even transitively.
This is an issue if using the C backend from Zig, where usage of C FILE
api is not needed.

Fixes BNFC#381.
@andreasabel andreasabel added C parser Issues concerning parser generating labels Sep 16, 2021
@andreasabel
Copy link
Member

Thanks for reporting and the PR, @enedil! Is this also a problem with the C++ backends?

@andreasabel andreasabel added this to the 2.9.3 milestone Sep 16, 2021
@enedil
Copy link
Contributor Author

enedil commented Sep 16, 2021

Thanks for reporting and the PR, @enedil! Is this also a problem with the C++ backends?

It doesn't, since Parser.H includes vector and string, which transitively usually include lots of other standard headers. But that is not guaranteed. I can make this addition as well. Latest forced push also fixes the C++ version.

enedil added a commit to enedil/bnfc that referenced this issue Sep 16, 2021
Parser.h uses FILE*, however doesn't include stdio.h, even transitively.
This is an issue if using the C backend from Zig, where usage of C FILE
api is not needed. The problem also is present in the CPP backend and
hereby fixed.

Fixes BNFC#381.
@andreasabel andreasabel self-assigned this Sep 16, 2021
andreasabel pushed a commit that referenced this issue Sep 16, 2021
Parser.h uses FILE*, however doesn't include stdio.h, even transitively.
This is an issue if using the C backend from Zig, where usage of C FILE
api is not needed. The problem also is present in the CPP backend and
hereby fixed.

Fixes #381.
@andreasabel
Copy link
Member

Thanks @enedil, this is now fixed on master.

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

Successfully merging a pull request may close this issue.

2 participants