Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

warning C4100: 'x' : unreferenced formal parameter

0 views
Skip to first unread message

Doug Harrison

unread,
Jun 23, 1997, 3:00:00 AM6/23/97
to

On Mon, 23 Jun 1997 12:15:38 -0700, "Sam Lee" <sam...@digitaldj.com>
wrote:

>There are cases when this warning actually helps....but in most cases this
>warning is annoying and clutters the build window.
>
>Anyone know of a clean way of saying to the compiler, "Hey I know this
>parameter is not being used."
>
>I thought of using
> if (x);
>
>but was wondering if there is something better.

Don't name the parameter.

--
Doug Harrison
dHar...@worldnet.att.net

Sam Lee

unread,
Jun 23, 1997, 3:00:00 AM6/23/97
to

There are cases when this warning actually helps....but in most cases this
warning is annoying and clutters the build window.

Anyone know of a clean way of saying to the compiler, "Hey I know this
parameter is not being used."

I thought of using
if (x);

but was wondering if there is something better.

Thanks.

Sam

Curtis Jewell

unread,
Jun 24, 1997, 3:00:00 AM6/24/97
to

Sam Lee wrote in article <01bc800a$5b6b2cb0$3ebab9cd@sl1>...

Yes.
In your .CPP file, start your routine like this:

void CYourClass::CYourRoutine(int /* x */)
{
...
}

In other words, comment out where the variable is actually NAMED. Do NOT comment out the
TYPE, or it'll think you are overloading.

--Curtis


Scott Gilbert

unread,
Jun 28, 1997, 3:00:00 AM6/28/97
to

>
> >Anyone know of a clean way of saying to the compiler, "Hey I know this
> >parameter is not being used."
>
> >I thought of using
> > if (x);
>

I was always under the impression that the standard way of doing it was:

void func(int Used, int ReservedForLater) {
(void) ReservedForLater;
}

I tend to do this a lot when I'm creating an interface and I suspect that
later I will have some flags that might slightly modify it's behavior.

David Wilson

unread,
Jun 29, 1997, 3:00:00 AM6/29/97
to

Two methods spring to mind:
1. Leave the parameter unnamed:
void func(int Used, int)
{
Used++;
}
2. Use the MFC macro UNUSED() [see afxpriv.h]:
void func(int Used, int Unused)
{
UNUSED(Unused);
Used++;
}

Scott Gilbert <sc...@nospam.smoothmove.com> wrote in article
<01bc8407$27f841f0$df89d8cd@atlantis>...

Scott Gilbert

unread,
Jun 30, 1997, 3:00:00 AM6/30/97
to


D McMath <McM...@worldnet.att.net> wrote in article
<33B712...@worldnet.att.net>...
>
> I just set it equal to itself with a note.
> x = x; /*** TO BE DONE *** USE THIS VARIABLE ***/
> P. McMath
>

I guess that's just fine as well. I can imagine that x is a class though
and that the operator = gets called with possible side effects. I prefer:

(void) x;

only because I can't think of a single case where it would do anything at
all. Just a matter of style I guess.

One other person mentioned using the macros provided by Windows. I dislike
this idea because it adds an unneeded dependency to the Windows where one
shouldn't be. We had a problem just recently where the person defining our
external interfaces decided to use a BITMAPINFO to contain a bunch of data
even though the code did not rely on windows other than that. This ended
up biting a tiny bit when the otherwise platform independent code needed to
be ported to the Mac. Now some poor Mac person has to use the totally
alien notion of a BITMAPINFO structure... Oh well.


0 new messages