2010-04-05 03:21 PM
Function return issue
2011-05-17 06:07 AM
Hi,
you are putting the result of your function into a local variable that is never used -> it is probably optimized out. Try to use a global variable, it should work. Regards, Luca (Cosmic)2011-05-17 06:07 AM
int main( void )
{
unsigned short usResult;
usResult = Func();
if ( 0 == usResult )
{
usResult = 1;
}
while( 1 );
return0;
}
... does get a returned value in usResult since it is referenced after the call to func(). So, compilers are getting that clever - even on a debug build with no optimization.
Always a new lesson to learn in this business - thank you for your response.
2011-05-17 06:07 AM
>> So, compilers are getting that clever - even on a debug build with no optimization
Actually optimizations are done in different compiler passes: the parser, the code generator and the optimizer itself: when you ''turn off the optimizations'' you justr disable the last component.