So i have some code like this:
void foo (int, int);
void bar ( )
{
//Do Stuff
#if (IMPORTANT == 1)
foo (1, 2);
#endif
}
When doing a compile without “IMPORTANT” I get a compiler Warning that foo is defined and never referenced. Which got me thinking (that is the problem).
So to fix this i just added the same #if (IMPORTANT == 1) around the function definition etc… to remove the warning, and then I started to wonder if there was a different way to suppress that warning on that function. I was looking at “unused” GCC attrib and didn’t know if functions had the same attribute i could set? Is there even another way to suppress it that suppresses that warning for only that function and not the file?
There might be compiler option(s) to suppress this warning. However, one trick is this:
It should suppress this warning.
You could write a macro:
As you can see, the definition of
fooitself suppresses the warning.