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

ES.30: Don’t use macros for program text manipulation - example warnings #2152

Open
jonnygrant opened this issue Oct 18, 2023 · 3 comments

Comments

@jonnygrant
Copy link

jonnygrant commented Oct 18, 2023

There is a warning about the unused x,y params in the example - Can those x,y there be removed?

<source>: In function 'void f(int, int)':
<source>:17:12: warning: unused parameter 'x' [-Wunused-parameter]
   17 | void f(int x, int y)
      |        ~~~~^
<source>:17:19: warning: unused parameter 'y' [-Wunused-parameter]
   17 | void f(int x, int y)
      |               ~~~~^

https://godbolt.org/z/hb41sfnsb

@jwakely
Copy link
Contributor

jwakely commented Oct 18, 2023

They're presumably "used" in the "// ..." part of the function that isn't shown.

Why does it matter if you get those warnings for the example? It's not a meaningful example that you can reuse in your own code.

@jwakely
Copy link
Contributor

jwakely commented Oct 18, 2023

Examples should be valid C++, so fixing the earlier error was useful. I don't see why an example that says void foo(int, int) is better than one that says void foo(int x, int y) though. If they're not named, why are they even there? Just do void foo() ... but then it becomes a less realistic and therefore less useful example.

@jonnygrant
Copy link
Author

Those unused parameters don't appear relevant to the example that converts enums to strings to make them useful for the reader. We can close it if you think differently.

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

2 participants