Unknown Compiler Warning

  • Thread starter Adam Hartshorne
  • Start date
A

Adam Hartshorne

Hi All,

I was wonder if somebody could tell me about this warning, as I have
written a fairly large application and I am gettting lots and lots of
these warning. I have no real clue what they mean and how to get rid of them

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' : unreferenced
formal parameter

Any help would be much appreciated,

Adam
 
V

Victor Bazarov

Adam said:
I was wonder if somebody could tell me about this warning, as I have
written a fairly large application and I am gettting lots and lots of
these warning. I have no real clue what they mean and how to get rid of
them

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' : unreferenced
formal parameter

Any help would be much appreciated,

This is the last time I will do this: put your cursor on the 'C4100' thing
in the "Build" window and press F1. Enjoy the online help provided to you
by your product. Alternatively, go to "Help" and search for 'C4100'.

The usual "Unused formal argument" comes from compiling a function that
declares an argument _with_ a name and never uses it:

int foo(double d) {
return 42; // 'd' is not used here
}

V
 
D

Default User

Adam said:
Hi All,

I was wonder if somebody could tell me about this warning, as I have
written a fairly large application and I am gettting lots and lots of
these warning. I have no real clue what they mean and how to get rid
of them

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' : unreferenced
formal parameter

Any help would be much appreciated,

It's difficult to say, because you (I guess) assume that we can
psychically look at your code. However, that's usually a warning when a
formal parameter isn't referenced.

If that doesn't help, read the FAQ about how to post a proper question.



Brian
 
P

Pete Becker

Adam said:
Hi All,

I was wonder if somebody could tell me about this warning, as I have
written a fairly large application and I am gettting lots and lots of
these warning. I have no real clue what they mean and how to get rid of
them

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' : unreferenced
formal parameter

Turn off the warning.

It gets generated for code like this:

int f(int i)
{
return 1;
}

There's nothing wrong with that code. Sometimes you need extra arguments
for consistency with other functions, even if those arguments aren't
used in some cases.

A trick that usually silences this warning is to use the argument in
some trivial way:

int f(int i)
{
i = i;
return 1;
}

Now the argument is used. Of course, you might get a warning that the
code has no effect, and you then have to write something to quiet that
warning. You can play this game for hours if you like. Or you can turn
off stupid warnings and get on with real work.

Most C++ compilers won't give this warning if you don't give the
argument a name, but that trick won't work if your code also has to
compile as C, because C requires a name there.
 
A

Adam Hartshorne

Pete said:
Turn off the warning.

It gets generated for code like this:

int f(int i)
{
return 1;
}

There's nothing wrong with that code. Sometimes you need extra arguments
for consistency with other functions, even if those arguments aren't
used in some cases.

A trick that usually silences this warning is to use the argument in
some trivial way:

int f(int i)
{
i = i;
return 1;
}

Now the argument is used. Of course, you might get a warning that the
code has no effect, and you then have to write something to quiet that
warning. You can play this game for hours if you like. Or you can turn
off stupid warnings and get on with real work.

Most C++ compilers won't give this warning if you don't give the
argument a name, but that trick won't work if your code also has to
compile as C, because C requires a name there.

Ok I understand what you are saying. However I haven't intensionally
used xlocale, i don't even know what it does.

Adam
 
A

Adam Hartshorne

Pete said:
Turn off the warning.

It gets generated for code like this:

int f(int i)
{
return 1;
}

There's nothing wrong with that code. Sometimes you need extra arguments
for consistency with other functions, even if those arguments aren't
used in some cases.

A trick that usually silences this warning is to use the argument in
some trivial way:

int f(int i)
{
i = i;
return 1;
}

Now the argument is used. Of course, you might get a warning that the
code has no effect, and you then have to write something to quiet that
warning. You can play this game for hours if you like. Or you can turn
off stupid warnings and get on with real work.

Most C++ compilers won't give this warning if you don't give the
argument a name, but that trick won't work if your code also has to
compile as C, because C requires a name there.

Thanks for the answer, I had kind of guess that, but I don't
intensionally use xlocale, I don't even know what it does.

Adam
 
A

Alf P. Steinbach

* Adam Hartshorne:
I was wonder if somebody could tell me about this warning, as I have
written a fairly large application and I am gettting lots and lots of
these warning. I have no real clue what they mean and how to get rid of
them

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' : unreferenced
formal parameter

Any help would be much appreciated,

Since the warning is generated for code in the standard library, I think
the best advice is what Pete Becker wrote, to turn off that warning.

Such warnings are known as 'silly-warnings', and the compiler you're
using spews out so indecently many of them that the same firm has a
habit of listing all the #pragma's that turn them off, in some central
place in their code.

For your own code, simply don't name an unreferenced formal argument.
 
P

Pete Becker

Adam said:
Ok I understand what you are saying. However I haven't intensionally
used xlocale, i don't even know what it does.

I know. I was ranting about stupid warnings. This is one you should just
turn off.
 
M

Martin Vejnar

Pete said:
Turn off the warning.

It gets generated for code like this:

int f(int i)
{
return 1;
}

There's nothing wrong with that code. Sometimes you need extra arguments
for consistency with other functions, even if those arguments aren't
used in some cases.

A trick that usually silences this warning is to use the argument in
some trivial way:

int f(int i)
{
i = i;
return 1;
}

I think the warning will disappear if you do

int f(int /*i*/)
{
return 1;
}
 
A

Adam Hartshorne

Martin said:
I think the warning will disappear if you do

int f(int /*i*/)
{
return 1;
}

AS I have mentioned before I can't / don't want to do this as the
warning is coming from xlocale, a header file which is built in to
visual studio and one which i have not altered or directly referenced!!!!

Adam
 
M

Martin Vejnar

Adam said:
Martin said:
Pete said:
Adam Hartshorne wrote:

[snip]

C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xlocale(609) : warning C4100: '_Lobj' :
unreferenced formal parameter

[snip]

I think the warning will disappear if you do

int f(int /*i*/)
{
return 1;
}

AS I have mentioned before I can't / don't want to do this as the
warning is coming from xlocale, a header file which is built in to
visual studio and one which i have not altered or directly referenced!!!!

When it comes to VS2003 I cannot say for sure, but on VS2005 the
<xlocale> header is referenced through multiple levels of indirection
from, for example, <iostream>. I'd say that the same thing is happening
to you.

Why are you worried about fixing a buggy (inconvenient) header file?

There is '/wd' option for compiler that can be used to disable specific
warnings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top