Valhalla Legends Forums Archive | C/C++ Programming | Warning Level 4 C4100: unreferenced formal parameter

AuthorMessageTime
Mephisto
What does this warning mean exactly and how can it be corrected?  I've searched online and couldn't find anything.
October 22, 2004, 12:35 AM
Mephisto
Nevermind, figured it out.
October 22, 2004, 12:38 AM
Myndfyr
[quote author=Mephisto link=topic=9275.msg85606#msg85606 date=1098405529]
Nevermind, figured it out.
[/quote]

As we all have asked other people who have done the same thing: do you want to share the information so we know for future reference?
October 22, 2004, 12:41 AM
Mephisto
Yes.  It's a level 4 warning in VS.NET 2003 labeled C4100 called "unreferenced formal parameter."  It's basically just a parameter that you pass to a function that you never use (reference).  So if you pass in an integer variable, and you never use it, you'll get that warning.  Note that level 4 warnings are information warnings and ignoring them won't affect your program in a seriously negative way (for instance, some level 1 - 3 warnings if ignored often lead to runtime crashes).
October 22, 2004, 1:04 AM
Myndfyr
I've seen 4100 listed elsewhere as "Unreferenced formal parameter" -- are you sure it's pointer?

Anyway, thanks for the info.  You're right about it not affecting your program in a negative way, but you have to ask yourself -- is my design really that good if I'm never using a parameter?
October 22, 2004, 1:11 AM
Mephisto
[quote author=MyndFyre link=topic=9275.msg85622#msg85622 date=1098407480]
I've seen 4100 listed elsewhere as "Unreferenced formal parameter" -- are you sure it's pointer?

Anyway, thanks for the info.  You're right about it not affecting your program in a negative way, but you have to ask yourself -- is my design really that good if I'm never using a parameter?
[/quote]

Yeah, you're right.  I overlooked what it said.  I edited my posts accordingly...
October 22, 2004, 2:04 AM
Grok
Warnings are a kick-ass way to get a free programming guru to help you write better code.  It has been pointed out in many programming style and technique books that you should get as much help from the compiler as possible.  The guidance provided should be heeded until you know why it shouldn't.  That is to say, fix the compiler warnings until you have a specific reason for not fixing it.

I'll give you a chess metaphor.  There are well-known guidance rules that you should move knights before bishops, do not move your queen out early, move one or two pawns and support them, but leave them be!  Well these are not hard-and-fast, but if you are a novice and do not know WHY you want to violate one of them, it's probably best to follow them most of the time.

In programming it is much the same thing, you listen to the IDIOMS provided by the experienced people and try to follow those yourself, most of the time.  The compiler warnings are one such source of help.  When you get experienced enough to know why you're in a situation that the idioms do not apply, or the warnings do not apply, do your own thing!
October 24, 2004, 5:34 PM
Mephisto
Thanks for the philosophy Grok.  :)  I decided that one of the best options to fix a lot of the bugs I've been experiencing with my bot program was to turn the warning level up to 4 and go through each warning and fix them.  I got them fixed and not only did fixing them fix a few bugs I didn't even know about, but also when fixing them, I encountered many new bugs and buggy code and fixed some of the ones that I knew existed.  I'll never ignore compiler warnings again.  :)
October 24, 2004, 11:34 PM
Myndfyr
Good man.
October 24, 2004, 11:38 PM

Search