Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C > best way to sup...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 15 Topic 25868 of 27670
Post > Topic >>

best way to suppress "unused" warning?

by Rex Mottram <rexm@[EMAIL PROTECTED] > Apr 24, 2008 at 09:05 PM

I'm using an API which does a lot of callbacks. In classic callback 
style, each routine provides a void * pointer to carry user-defined 
data. Sometimes, however, the user-defined pointer is not needed which 
causes the compiler to spit out a "helpful" warning. For example:

% cat unused.c
#include <stdio.h>
int
foo(char *str, void *data)
{
     puts(str);
     return 0;
}

% gcc -c -W -Wall unused.c
unused.c:4: warning: unused parameter 'data'

I'm looking for an appropriate (safe, reasonably self-do***enting) way 
of suppressing that warning in cases where I expect it (thus I'm not 
looking for the compiler flags to suppress the warning - I just want to 
be able to mark the places I know about). I've used constructs like

	data = data;
	data++;
	if (data != data) return;

And they all work but are a little too obfuscated for my taste. I'm sure 
many other people have run into this - is there a recommended technique?

RM
 




 15 Posts in Topic:
best way to suppress "unused" warning?
Rex Mottram <rexm@[EMA  2008-04-24 21:05:24 
Re: best way to suppress "unused" warning?
Richard Heathfield <rj  2008-04-25 01:24:18 
Re: best way to suppress "unused" warning?
Eric Sosman <esosman@[  2008-04-24 21:27:17 
Re: best way to suppress "unused" warning?
Antoninus Twink <nospa  2008-04-25 16:35:12 
Re: best way to suppress "unused" warning?
"Joachim Schmitz&quo  2008-04-25 16:42:31 
Re: best way to suppress "unused" warning?
Ian Collins <ian-news@  2008-04-29 21:05:54 
Re: best way to suppress "unused" warning?
richard@[EMAIL PROTECTED]  2008-04-25 14:50:35 
Re: best way to suppress "unused" warning?
CBFalconer <cbfalconer  2008-04-25 16:04:36 
Re: best way to suppress "unused" warning?
fred.l.kleinschmidt@[EMAI  2008-04-25 09:12:24 
Re: best way to suppress "unused" warning?
David Tiktin <dtiktin@  2008-04-28 19:04:07 
Re: best way to suppress "unused" warning?
Peter Nilsson <airia@[  2008-04-28 20:04:28 
Re: best way to suppress "unused" warning?
Richard Heathfield <rj  2008-04-29 03:17:23 
Re: best way to suppress "unused" warning?
"Joachim Schmitz&quo  2008-04-29 10:48:03 
Re: best way to suppress "unused" warning?
"Joachim Schmitz&quo  2008-04-29 10:58:01 
Re: best way to suppress "unused" warning?
Himanshu Chauhan <chau  2008-04-29 16:05:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 22:11:13 CDT 2008.