"William DePalo [MVP VC++ ]" <wi***********@mvps.org> wrote in message news:<#r**************@TK2MSFTNGP09.phx.gbl>...
"Steve Richter" <co********@yahoo.com> wrote in message
news:c0**************************@posting.google.c om... I finally get my 6.0 c++ code to compile in .NET. Now there are a lot
of warnings in the .NET compile. Under 6.0, the complile of a very
large body of code results in 25 warnings. With C++ .NET, the same
file compiles with 228 errors.
Here is an example:
int SecondsToMilliSeconds( double nSeconds )
{
return( nSeconds * 1000 ) ;
}
I just copied that function into a source file and compiled it with 6.0. I
see the same warning. Are you sure that the 6.0 project was set to compile
at the same warning level and/or that someone did not explicitly disable
some warnings there?
nothing that I am aware of. but there is a lot in all of this I am
not aware of.
Why not inhibit the warnings you deem innocuous by means of a cast or
pragma?
I am afraid of casting. Kind of like how Kramer in Seinfeld is afraid
of clowns. ( I work half my time on an IBM as400. The system is very
nice, but if you break the rules, they break your bones! )
In this case, is that the official way to tell the compiler that I am
aware that I might lose some data in the assignment?
return (int) ( nSeconds * 1000 ) ;
I'd prefer some sort of built in operator:
int nValue = _DoubleToInt( nSeconds * 1000 ) ;
Another warning I get a lot is from the following:
int CalcSomething( int Input )
{
switch( Input )
{
case 1:
return 25 ;
default:
LogAndThrowTextException( L"Input to CalcSomething is no good"
) ;
return 0 ; // never runs. but get warning if not present.
}
}
The compiler does not know that the "LogAndThrowTextException"
function throws an exception. If I dont add the "return" stmt after
the "LogAndThrow...", then I get an all code paths dont return a
value. But I dont like inserting the "return 0" because I think it
adds to code clutter.
It would be better for me if I there was a non standard way to tell
the compiler that "LogAndThrowTextException" always throws an
exception and is in affect a "returning code path".
thanks,
-Steve