How to suppress warning in VC++

  • Thread starter Thread starter J Swift
  • Start date Start date
J

J Swift

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?
 
J said:
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
 
J Swift said:
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
 
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
 
John L. DeVito said:
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

Thanks to all who answered... I got through it and learned more by your
responses
 
Back
Top