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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top