-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
[Feature request] Warn when a macro argument is not used #1579
Comments
There are definitely some macros which just take a "flag" argument whose actual value doesn't matter (often it's 1, could be Syntax "to specify how many arguments they want to be given" sounds like it would develop into #912. |
So, in this hypothetical: macro foo
pusho Wno-unused-macro-arg
db \1, \3
popo
endm
foo 1, 2, 3 The On the other hand, users could just put a (You could also do |
Oops, we don't expand things in comments, so This also does not work: if 0
println "\#"
endc (In hindsight that also makes sense. If you did Things that do work: redef _discard equs "\#" assert isconst("\#") Or, of course, local |
Would I'm also not entirely sure who the warning is for. Is it for the user of the macro, who might've specified too many arguments? Or, is it for the implementor of the macro, who might've forgotten to do something? In my opinion, given this constraint, I see no real circumstance in which |
Good point about |
Macros will, logically, error out when they are passed too few arguments. But, by nature, extraneous arguments are simply ignored. This can be intentional, but I expect that this would be rare; so, I'm suggesting
-Wunused-macro-arg
enabled by-Wall
.In theory, we could also add some syntax for macros to specify how many arguments they want to be given; but I expect that adoption would be low, and thus I'm not sure it would be worth the implementation effort.
The text was updated successfully, but these errors were encountered: