Hello
It is a best practise to initialise a variable at the time of declaration.
int TMyClass::GetValue()
{
int vStatus = OK;
// A function returns a value
vStatus = DoSomeThingAndReturnErrorCode();
if(!vStatus)
//Do something
else
return(vStatus);
}
In the debug mode, a statement like this int vStatus = OK;
is causing no issues during DEBUG MODE build.
The same when build in RELEASE MODE, throws a warning saying w8004: 'vStatus' is assigned a value that is never used.
Also, i am using the same variable further down my code with in the same function,like this if(!vStatus)
and also i return the value of return(vStatus);
When i looked at the web for pointers on this debug Vs Release, compilers expect you to initialise your varible at the time of declaring it. Link
I am using Borland developer studio 6 with windows 2003 server.
Any pointers will help me to understand this issue.
Thanks
Raj