

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I remember reading before about the significance (or lack thereof) between including a parameter name in a function declaration and not including one. But I can't remember what it was that I read or where I read it.

for example,

void do_something(int *); // No parameter name included, only type.


void do_something(int * i); // type AND parameter name included.

So what's the difference between these two declarations? Thanks for reading and maybe answering this possibly trivial question.

-- UPDATE --

Okay, so the thing I had read was a set of style guidelines from an old professor of mine warning against including a parameter name in function definition and NOT using the parameter in the function.

void do_something(int * i) { //code that doesn't use i;} //BAD
void do_something(int *) { //code that doesn't use i;} //OK
share|improve this question
up vote 12 down vote accepted

There is no difference, as far as the compiler is concerned.

Adding meaningful parameter names is a helpful form of documentation, though.

share|improve this answer

There is no technical difference between those declarations. If you instead had

void accumulate_stats(int * count);

or something similarly descriptive, it would be an improvement in self-documentation.

share|improve this answer

The difference is that the second version could be more readable if you choose a good parameter name. Nothing more to say ;-)

share|improve this answer

In a forward declaration, there should be no difference. They will both describe the same memory layout for the call, so they should be completely interchangeable.

share|improve this answer

For a forward declaration, it doesn't make any difference.

In the actual definition, a parameter without a name isn't checked for use. It's a way to have unused parameters without some UNUSED_PARAM(x) macro or some other trickery whose only purpose is to shut the compiler up about it.

share|improve this answer
Macros are sort of evil, what with name collisions, multiple evaluations of args, etc. Sometimes they're practically necessary, but it's a good idea to avoid them in general. So, better use function template unusedParam. That is, if you can't live with the warnings. Cheers, – Cheers and hth. - Alf Nov 10 '10 at 23:36
Agreed, macros are evil. But IMO, any code that exists only to say "yeah, i'm not doing anything with this argument. Shut up, you stupid compiler!" isn't much better. – cHao Nov 10 '10 at 23:39
Which is why the (void)argName; syntax exists. That tells the compiler that argName is "used", though it evaluates to a no-op. – Jonathan Grynspan Nov 11 '10 at 1:01
@Jonathan: Again, any extra code whose only purpose is to shut the compiler up, is pretty ugly IMO. Why name the variable at all if you're not going to use it? – cHao Nov 11 '10 at 5:31
@cHao: I'm not disagreeing. Just saying--there is a standard syntax for this particular warning-dodge, so there's no need for a macro. – Jonathan Grynspan Nov 11 '10 at 6:40

Your Answer


