문제

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