[comp.lang.c++] Dealing with unused arguments

brad@bwilab3.UUCP (Bradley Ward) (12/12/90)

Just wanted to say thanks to several of you net-landers that
answered my question of last week via e-mail, and to post the
answer for the benifit of all.  The question was:

<< 
<< When I write a callback routine such as those used by X windows, many
<< times I don't need to use the "client_data" argument.  But the C++
<< compiler issues a "unused argument" warning.  I hate to have warnings
<< generated, so I have been doing stuff like putting the statement
<< "client_data = client_data;" in the callback simply to eliminate this
<< compiler warning.
<< 
<< Any ideas on how to handle this more elegantly ?

And the answer was:

< Yes, declare the argument without giving it a name:
<
<	main(int argc, char**)
<
< is a way of declaring main() and saying that you'll use the value of the
< first argument, but are ignoring the second argument. Do similarly for
< client_data: declare its type but not its name.
<

Thanks again, guys...

Bradley Ward                                      Phone: 404-396-4292
BRADLEY WARD, INC.                                FAX:   404-396-6509
5901-A Peachtree Dunwoody Road, N.E. Suite 415   
Atlanta, Georgia   30328
...!uunet!gatech!galbp!bwilab3!brad