I've narrow down the problem to a faulty casting.
The problem can be reproduce with this small piece of code:
(using CW9.2 and SDK 5R3)
unsigned char uchrI[10];
int intJ;
uchrI[5]=129;
intJ=uchrI[5];
if (intJ<0) // Here the debuger tells me that intJ has a value of 129
(0x0081 in hex) which is positive for an integer
{
intJ=0; // but the value is evaluated to a negative value and the
condition become true for intJ>=128
}
I've try to type cast like this:
intJ=(int)uchrI[5];
and also like this:
intJ=(unsigned int)uchrI[5];
But it gives me the same result.
if ((int)intJ<0) also gives the same problem.
I've also try to pass thru a temporary variable like this:
unsigned char uchrI[10];
unsigned char uchrTmp;
int intJ;
uchrI[5]=129;
uchrTmp=uchrI[5];
intJ=uchrTmp;
if (intJ<0)
{
intJ=0;
}
But without success.
It is not a case of optimisation (the optimisation is turned off)
jcpalm was originaly build and tested with CW6 ans SDK 3.5 and was working
fine.
Any clues on this change of beavior from the compiler?
--
Regis St-Gelais
www.laubrass.com
--
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/