tags:

views:

98

answers:

3

What's the best way to suppress "unused parameter" warning in C code.

For instance,

Bool NullFunc(const struct timespec *when, const char *who, unsigned short format, void *data, int len)
{
   return TRUE;
}

In C++ I was able to put /.../ around the parameters. But not in C of course.

It gives me "error: parameter name omitted".

Some tips would be appreciated.

+6  A: 

I usually write a macro like this:

#define UNUSED(x) (void)(x)

You can use this macro for all your unused parameters.

(Note that this works on any compiler.)

Job
ahhhh a for awesome. thanx man.
kuzyt
+5  A: 

In gcc, you can label the parameter with the unused attribute.

Philip Potter
+1  A: 

I've seen this style beeing used:

if (when || who || format || data || len);
bluntkhan