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

printf.h: definition of ATTR_PRINTF is invalid without __GNUC__ #126

Closed
smcpeak opened this issue Apr 21, 2022 · 3 comments
Closed

printf.h: definition of ATTR_PRINTF is invalid without __GNUC__ #126

smcpeak opened this issue Apr 21, 2022 · 3 comments
Assignees
Labels
resolved-on-develop A changeset fixing this issue has been commiutted to the development branch

Comments

@smcpeak
Copy link

smcpeak commented Apr 21, 2022

As of commit 87878b2, printf.h when preprocessed without __GNUC__ has this macro definition:

# define ATTR_PRINTF((one_based_format_index), (first_arg))

This is invalid since the macro parameters have extra parentheses. cpp -undef (which does not set __GNUC__) complains:

$ cpp -undef printf.h >/dev/null
printf.h:56:22: error: expected parameter name, found "("
   56 | # define ATTR_PRINTF((one_based_format_index), (first_arg))
      |                      ^
Exit 1
$ cpp --version
cpp (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

In the original commit, that line should not have been changed.

Ideally, there should also be an automated test that exercises this printf implementation without __GNUC__, as that would have caught this error.

@eyalroz
Copy link
Owner

eyalroz commented Apr 22, 2022

First, thank you for reporting this bug.

Now, would you like to submit a PR? Indeed, I currently only test on GNUC-ish compilers. Perhaps I should work on creating an MSVC workflow.

@smcpeak
Copy link
Author

smcpeak commented Apr 22, 2022

I hesitate to submit a PR since (ideally) it should include a test and I'm not sure what would fit best in this project. (And, as I'm working on other things, I'm not able to properly explore that currently.)

However, as for how to test, one suggestion is to preprocess with cpp -undef to get a "compiler-agnostic" version and then feed that to GCC. That's effectively what I was doing when I ran into this.

@eyalroz
Copy link
Owner

eyalroz commented Apr 22, 2022

@smcpeak : Well, I don't know about cpp -undef. It` will break the library in a dozen ways. I think it undefines more than you might expect.

@eyalroz eyalroz self-assigned this Apr 22, 2022
@eyalroz eyalroz added the resolved-on-develop A changeset fixing this issue has been commiutted to the development branch label Apr 22, 2022
@eyalroz eyalroz added resolved-on-develop A changeset fixing this issue has been commiutted to the development branch and removed resolved-on-develop A changeset fixing this issue has been commiutted to the development branch labels Sep 16, 2022
@eyalroz eyalroz mentioned this issue Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolved-on-develop A changeset fixing this issue has been commiutted to the development branch
Projects
None yet
Development

No branches or pull requests

2 participants