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

Warnings in compilation for C89 (ANSI C) #79

Closed
felipemarkson opened this issue Dec 30, 2023 · 3 comments
Closed

Warnings in compilation for C89 (ANSI C) #79

felipemarkson opened this issue Dec 30, 2023 · 3 comments

Comments

@felipemarkson
Copy link

If you try to compile picohttpparser.c using C89 you get a couple of warnings:

gcc -std=c89 -pedantic -c picohttpparser.c

OUTPUT

picohttpparser.c: In function ‘parse_headers’:
picohttpparser.c:336:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  336 |         const char *value;
      |         ^~~~~
picohttpparser.c:342:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
  342 |         const char *value_end = value + value_len;
      |         ^~~~~

As picohttpparser does not allocate memory, it is great to use with micro-controllers which may not support C99.

This issue is to solve these warning.

@felipemarkson felipemarkson changed the title Solving warnings in compilation for C89 (ANSI C) is not possible Warnings in compilation for C89 (ANSI C) is not possible Dec 30, 2023
@felipemarkson felipemarkson changed the title Warnings in compilation for C89 (ANSI C) is not possible Warnings in compilation for C89 (ANSI C) Dec 30, 2023
@kazuho
Copy link
Member

kazuho commented Dec 30, 2023

Thank you for opening the issue and filing a PR.

In our coding style, we intentionally allow use of some C99 dialects; see https://github.com/h2o/h2o/wiki/Coding-Style.

Would it be possible for you to solve the issue by changing the compiler options?

@oerdnj
Copy link

oerdnj commented Dec 30, 2023

Just to chime in as a user of the library. C99 is now 25 years old. Lack of tooling for fringe platforms should not be an argument to compromise on the code clarity and all features listed in #2188 greatly improve the code style.

As a matter of fact, I am big fan of all C code should gradually move to at least C11/C17, but that’s another story ;)

@felipemarkson
Copy link
Author

felipemarkson commented Dec 31, 2023

In our coding style, we intentionally allow use of some C99 dialects; see https://github.com/h2o/h2o/wiki/Coding-Style.

@kazuho Oh! I hadn't realized that. Since the warning is caused by only three lines of code, I thought this library supported ANSI C. PR #80 should be rejected then and I will close this issue if you prefer.

Thanks.

@kazuho kazuho closed this as completed Jan 25, 2024
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

Successfully merging a pull request may close this issue.

3 participants