Pages

Friday, June 15, 2012

C++ UNREFERENCED_PARAMETER

Let's start with UNREFERENCED_PARAMEER. This macro is defined in winnt.h, like so:

#define UNREFERENCED_PARAMETER(P) (P)
 

In other words, UNREFERENCED_PARAMETER expands to the parameter or expression passed.Its purpose is to avoid compiler warnings about unreferenced parameters.Many programmers, including yours truly,
like to compile with the highest warning level,Level 4 (/W4).Level 4 warnings fall into the category of "things that can be safely ignored." Little infelicities that won't break your code, though they might make you look bad.For example, you might have some line of code in your program like this

int x=1;

but you never use x. Perhaps this line is left over from a time when you did use x,but then you removed the code and forgot to remove the variable.Warning Level 4 can find these minor mishaps.So why not let the compiler help you achieve the highest level of professionalism possible? Compiling with Level 4 is a way to show pride in your work. Level 4 is de rigueur if you're writing a library for public consumption. You don't want to force your developers to use a lower level to compile their code cleanly.

MSDN Link

No comments:

Post a Comment