A well-known and portable way to suppress C compiler warnings about unused variables is (see unused parameter warnings in C code):
#define UNUSED(x) (void)(x)
>
You can use compile time __VA_ARGS__
macro.
#define UNUSED(...) (void)(__VA_ARGS__)
UPDATE: After lot of trials, I came up to an optimized solution:
#define UNUSED(...) __VA_ARGS__
int main()
{
int e, x;
char **a, **b, *c, d[45];
x = x, UNUSED(a, b, c, d, e), x;
return 0;
}
NOTES:
It doesn't eliminate warnings completely but reduces them to just 3
same type of warnings:
warning: value computed is not used
The first and last x
ensure assignment of same datatypes.
I will say it is optimized because for any number of unused variables it gives 3
warnings (I may be wrong, please test it yourself and do report me if you get more) and the amount of code (MACRO manipulations) required to achieve it is less.
I am still working on it, will post if I reach to any better solution.