So I found this href="https://stackoverflow.com/questions/4851075/universally-compiler-independent-way-of-implementing-an-unused-macro-in-c-c/4851173#4851173">macro
on SO:
#define
UNUSED(x) (void)(sizeof((x),
0))
and this (still)
produces the following warning:
main.c:11:36:
warning: left-hand operand of comma expression has no effect [-Wunused-value]
#define UNUSED(x) (void)(sizeof((x),
0))
Whereas
the simpler version, a normal void
cast: #define
is
UNUSED(x) (void)(x)
warning-free.
What could be the reason behind
it? In general warnings are a sign of high-risk situations. Is here the given warning
really useful?
I am interested in
C-explanation.
No comments:
Post a Comment