Question

I am programming in C Linux.

I have a few functions in my code that i receive as parameters X parameters, but i do not use all of the parameters in it.

I am getting a warning of unused variables.

I would like the compiler to catch allot of warnings, except for this one.

What flag in the make file will do this trick?

Thanks Matt

Was it helpful?

Solution

Assuming this

int f(int x, int y)
{
  return y;
}

to provoke the warning mentiond by the OP.

For gcc just do this

int f(int x __attribute__ ((unused)), int y)
{
  return y;
}

to have the waninng disappear.


A more generic trick is to just do:

int f(int x, int y)
{
  x = x;
  return y;
}

For gcc specifing the option -Wno-unused-parameter should disable this warning.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top