[cfe-dev] rfc: winnt.h's UNREFERENCED_PARAMETER() vs clang's -Wunused-value

comex via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 13 01:21:50 PDT 2015


On Mon, Oct 12, 2015 at 7:41 PM, Richard Smith via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Perhaps I meant to write `f(x);` and wrote `(x);` instead, or my `x` is a
> callable and I meant to write `x();`. Using parens to mean "I am discarding
> this value" is novel, counter-intuitive, and just not a good pattern,
> whereas the very purpose of permitting casts to void is to allow explicitly
> discarding a value.

It could also be a macro defined to just return the argument - i.e.
the same definition as UNREFERENCED_PARAMETER, but for a different
purpose.  For example, /usr/include/xpc/base.h on OS X has:

#if __has_feature(objc_arc)
[..]
#define XPC_BRIDGEREF_BEGIN(xo) ((__bridge_retained void *)(xo))
[..]
#else // __has_feature(objc_arc)
[..]
#define XPC_BRIDGEREF_BEGIN(xo) (xo)
[..]
#endif // __has_feature(objc_arc)



More information about the cfe-dev mailing list