Warning Level 4
-
::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------
-
::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------
No it's not a problem, just asking you if your function prototype has a mistake in it or not. I think you can get it to keep quiet by doing somthing like this:
void Function(int foo)
{
foo; // By putting this here, C4100 should be surpressed
}Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]
-
No it's not a problem, just asking you if your function prototype has a mistake in it or not. I think you can get it to keep quiet by doing somthing like this:
void Function(int foo)
{
foo; // By putting this here, C4100 should be surpressed
}Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]
Joel Holdsworth wrote: I think you can get it to keep quiet by doing somthing like this:
void Function(int foo) { foo; // By putting this here, C4100 should be surpressed }
I had started doing that then thought um that might be bad, let’s see what every one else says. All of the function prototypes that I have created myself are fine. It mostly just the message over rides that cause this problem. Thanks much Joel ------------------------------- -
Joel Holdsworth wrote: I think you can get it to keep quiet by doing somthing like this:
void Function(int foo) { foo; // By putting this here, C4100 should be surpressed }
I had started doing that then thought um that might be bad, let’s see what every one else says. All of the function prototypes that I have created myself are fine. It mostly just the message over rides that cause this problem. Thanks much Joel -------------------------------Yeah you just rewminded me the other way to deal with the problem (probably more efficiant too) i this. Say my function has to be have the parameters WPARAM followed by LPARAM, you don't have to give these names:
int Function2(WPARAM, LPARAM param2)
{
param2 += 6; // We're using param2
}You see the WPARAM is still present in the parameter list, but is not referenced at all. I think the optimiser should reduce the two methods to producing the same code, but this way is a little more elegant. Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]
-
Yeah you just rewminded me the other way to deal with the problem (probably more efficiant too) i this. Say my function has to be have the parameters WPARAM followed by LPARAM, you don't have to give these names:
int Function2(WPARAM, LPARAM param2)
{
param2 += 6; // We're using param2
}You see the WPARAM is still present in the parameter list, but is not referenced at all. I think the optimiser should reduce the two methods to producing the same code, but this way is a little more elegant. Joel Holdsworth Wanna give me a job this summer? Check out my online CV and project history[^] - now available in MSWord format![^]
-
::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------
I've used
void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); }
andvoid Function(int param1, int /*param2*/) { }
I think there's another macro, can't remember it offhand.:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
-
I've used
void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); }
andvoid Function(int param1, int /*param2*/) { }
I think there's another macro, can't remember it offhand.:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
-
I've used
void Function(int param1, int param2) { UNREFERENCED_PARAMETER(param2); }
andvoid Function(int param1, int /*param2*/) { }
I think there's another macro, can't remember it offhand.:suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
Jack Squirrel wrote: I think there's another macro, can't remember it offhand. MFC's macros: "UNUSED" and "UNUSED_ALWAYS" will do that trick for you too :-D I also got the blogging virus..[^]
-
::Stupid Question Alert:: Compiling my application with warning level 4, I get a fair number of “warning C4100: (param name here) unreferenced formal parameter”. Is this something I should concern myself with or just ignore it? It was helpful in catching a couple of variables that where declared but unused. -------------------------------
-
This is the best way thought void Function(int param1, int /*param2*/) { } Papa while (TRUE) Papa.WillLove ( Bebe ) ;
-
Papa wrote: void Function(int param1, int /*param2*/) { } Yea know some how I bet your correct. Anyone else know for sure? Thx Much -------------------------------
-
The bug slayer, John Robbins, in his Debugging Applications for Microsoft .NET and Microsoft Windows (Great book btw) Papa while (TRUE) Papa.WillLove ( Bebe ) ;
Sounds good. Now that I’m at home and free to wander the net I found an article at http://msdn.microsoft.com/msdnmag/issues/05/05/CAtWork/default.aspx[^] Which comments on this very subject. They say it doesn’t really matter. I’m inclined to think that commenting the section out is a "little" cleaner way to go about it (after some experimentation). -------------------------------
-
Sounds good. Now that I’m at home and free to wander the net I found an article at http://msdn.microsoft.com/msdnmag/issues/05/05/CAtWork/default.aspx[^] Which comments on this very subject. They say it doesn’t really matter. I’m inclined to think that commenting the section out is a "little" cleaner way to go about it (after some experimentation). -------------------------------
I know that these macros often resolve to param = param; which is a junk code just to reference the param. The commenting of the param just instruct the compiler to *not see* the param in order to skip the warning Papa while (TRUE) Papa.WillLove ( Bebe ) ;