Reputation: 369
In C, what's the meaning of an underscore as a macro parameter?
#define FUNC(_) VALUE
Is it a dummy argument? any example for a use-case in which it'll fit?
Upvotes: 7
Views: 3371
Reputation: 53006
The _
has no special meaning, I suppose they used it because it looks like if the argument is not there.
The _
is just a valid identifier, and hence it's taken so the macro requires one parameter, but it keeps the macro definition looking as if there was no parameter.
#define FUNC(ignoredParameter) VALUE
would be exaclty the same.
Upvotes: 7
Reputation: 70422
In this case, the code can be read as:
FUNC
takes a single argument, but it doesn't care what it is. No matter what is passed in,VALUE
is the result.
A single _
is a valid identifier in C, and is thus suitable for use as a macro argument name.
Upvotes: 6