-1

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

alk
  • 69,737
  • 10
  • 105
  • 255
user690936
  • 985
  • 5
  • 13
  • 23
  • 2
    Did you try to google this? Also, you want this for all unused parameters in your project or just for some special functions? – Kiril Kirov Mar 18 '14 at 14:52
  • It would help if you specified your compiler (GCC?), the compiler flags you are currently using and the warning that you are receiving. If you are using GCC, normally the flag to disable that particular warning is shown, eg: `warning: ‘a’ is used uninitialized in this function [-Wuninitialized]` – Tom Fenech Mar 18 '14 at 14:56
  • 1
    @TomFenech: It's actually the option **en**abling the warning that is shown for newer gccs. To disable a particular warning prefix it with `no-`, which in this case would lead to the option `-Wno-uninitialized`. – alk Mar 18 '14 at 15:52

1 Answers1

0

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.

alk
  • 69,737
  • 10
  • 105
  • 255