469,623 Members | 899 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

How to suppress warning in VC++

I posted this question earlier but on the wrong usenet.
I have a warning below that I need to suppress

*warning C4018: '<' : signed/unsigned mismatch

I searched google, Microsoft help and MSDN for an answer but no luck.
I don't want to fix the cause because it's how the program is supposed to
work. It's part of an example in a text and the example suppresses a similar
warning in Borland. I am sure there must be a way to do this in dotnet, but
how?
Nov 17 '05 #1
4 12610
J Swift wrote:
I posted this question earlier but on the wrong usenet.
I have a warning below that I need to suppress

*warning C4018: '<' : signed/unsigned mismatch

I searched google, Microsoft help and MSDN for an answer but no luck.
I don't want to fix the cause because it's how the program is
supposed to work. It's part of an example in a text and the example
suppresses a similar warning in Borland. I am sure there must be a
way to do this in dotnet, but how?


Cast one of the operands to the other type.

e.g.

int i;
unsigned j;
// ...

if (unsigned(i) < j)
{
// ...
}

-cd
Nov 17 '05 #2

"J Swift" <ju**@hotmail.CUT.com> wrote in message
news:42******@nntp.zianet.com...
I posted this question earlier but on the wrong usenet.
I have a warning below that I need to suppress

*warning C4018: '<' : signed/unsigned mismatch

I searched google, Microsoft help and MSDN for an answer but no luck.
I don't want to fix the cause because it's how the program is supposed to
work. It's part of an example in a text and the example suppresses a similar warning in Borland. I am sure there must be a way to do this in dotnet, but how?


pragma warning (disable: 4018)

/Fredrik

Nov 17 '05 #3
If you are using VS.NET you can also lower your compilers warning level this
may help. For example go to Project->Properties under C\C++ change the
warning level to one lower than what it is currently set at and continue to
drop it until the warning goes away, or just turn off warning altogether
(not recommended). You can also do this is you are using the command line
version of the compiler by issue the /W<warning level number> ie /W3 /W2 /W1
etc or /W0 for no warnings.

Hope that helps.

John
"J Swift" <ju**@hotmail.CUT.com> wrote in message
news:42******@nntp.zianet.com...
I posted this question earlier but on the wrong usenet.
I have a warning below that I need to suppress

*warning C4018: '<' : signed/unsigned mismatch

I searched google, Microsoft help and MSDN for an answer but no luck.
I don't want to fix the cause because it's how the program is supposed to
work. It's part of an example in a text and the example suppresses a
similar warning in Borland. I am sure there must be a way to do this in
dotnet, but how?

Nov 17 '05 #4

"John L. DeVito" <sp**@digitalkhaos.net> wrote in message
news:KvOVd.92700$bu.75881@fed1read06...
If you are using VS.NET you can also lower your compilers warning level
this may help. For example go to Project->Properties under C\C++ change
the warning level to one lower than what it is currently set at and
continue to drop it until the warning goes away, or just turn off warning
altogether (not recommended). You can also do this is you are using the
command line version of the compiler by issue the /W<warning level number>
ie /W3 /W2 /W1 etc or /W0 for no warnings.

Hope that helps.

John
"J Swift" <ju**@hotmail.CUT.com> wrote in message
news:42******@nntp.zianet.com...
I posted this question earlier but on the wrong usenet.
I have a warning below that I need to suppress

*warning C4018: '<' : signed/unsigned mismatch

I searched google, Microsoft help and MSDN for an answer but no luck.
I don't want to fix the cause because it's how the program is supposed to
work. It's part of an example in a text and the example suppresses a
similar warning in Borland. I am sure there must be a way to do this in
dotnet, but how?



Thanks to all who answered... I got through it and learned more by your
responses
Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Krishna Srinivasan | last post: by
9 posts views Thread by Doug Ly | last post: by
4 posts views Thread by Susan Bricker | last post: by
5 posts views Thread by Robert A Riedel | last post: by
6 posts views Thread by Kim Hellan | last post: by
1 post views Thread by Chris Stankevitz | last post: by
13 posts views Thread by Rex Mottram | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.