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

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Sat Oct 10 14:52:44 PDT 2015


On Sat, Oct 10, 2015 at 02:50:33PM -0700, Nico Weber via cfe-dev wrote:
> 1. Don't. Tell people to not use UNREFERENCED_PARAMETER().
> 2. Have a winnt.h wrapper in lib/Headers that undefines this macro,
> include_next's regular winnt.h, undefines it again, and then defines it to
> something that doesn't trigger -Wunused-value (say, `(void)p`, or `do {
> (void) P; } while (0)` or similar).
> 3. Change clang's Wunused-value to check if the unused value is expanded
> from a macro that was defined in a system header that's spelled
> UNREFERENCED_PARAMETER.
> 
> 2 sounds like it has the highest chance of unintended side effects. 3 is a
> bit hacky, but seems nicest from a user's perspective and isn't worse than
> other things we do really.

(2) is what people have been told to use on other systems, at least the
cast to void part.

Joerg



More information about the cfe-dev mailing list