Hey Benoit, thx for the reply.
- no optimizations (-O0), default debugging info (-g).
After changing code to read k, I get the same result.
Torben.
UInt16 g_Stuff = 10;
UInt32 PilotMain (UInt16 cmd, void *cmdPBP, UInt16 launchFlags)
{
static UInt16 k = 0;
UInt16 j = 0;
k = k + 1;
j = k + 2;
return errNone;
}
"Benoit Cerrina" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> do you use some -O or similar optimization compilation flag?
> in the code bellow you never read the value of k and the compiler can
> detect it and skip some of your code.
> Benoit
> [EMAIL PROTECTED] wrote:
>
>>Could someone please tell me why compiling & debugging the following
>>simple code in DevSuite v1.2 *always* shows a value of k = 2, even though
>>it's been initialized to 0 and after it's incremented?
>>
>>Note that if the code is changed so that the global g_Stuff *isn't*
>>initialized, the debugger shows an initial value of k = 0, as expected.
>>
>>Also, why doesn't the static variable 'k' show up in the variables window
>>of the DevSuite debugger? I can only examine the value of 'k' by hovering
>>the mouse pointer over this variable in the code. If I make the variable
>>non-static, it *is* shown in the variables window while stepping through
>>the PilotMain function.
>>
>>UInt16 g_Stuff = 10;
>>
>>UInt32 PilotMain (UInt16 cmd, void *cmdPBP, UInt16 launchFlags)
>>
>>{
>>
>>static UInt16 k = 0;
>>
>>
>>k = k + 1;
>>
>>
>>return errNone;
>>
>>}
>>
>>Additional info:
>>
>>Emulator: Handspring Visor Deluxe, or Palm Vx (same result)
>>Compiler/Debugger: Palm Developer Suite v1.2, Managed Make 68K project
>>
>>Regards,
>>
>>Torben.
>>
>>
>
>
>
>
>
>
> ___________________________________________________________________________
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> Tlchargez cette version sur http://fr.messenger.yahoo.com
>
>
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/