How was the original code as written "nonportable"? It is badly written
code, and C compilers should dissallow this sort of syntax and admittedly
ANSI C specifies this as unspecified (hence, platform dependent) behavior.
However, according to standard implicit C conversion the -1 should be
upgraded to a 32 bit int (long in most cases) before assignment. So what you
say should never happen on a standard compiler.
You would, however, run into that sort of trouble the other way around.


Will


----- Original Message -----
From: "Armel Asselin" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, September 06, 2002 12:46 AM
Subject: RE: Unsigned Ints and -1


> Hello,
>
> your code snippets is non portable and bad code.
>
> UInt32 SPECIAL_VALUE = -1;
>
> means on some plateforms UInt32 SPECIAL_VALUE = 65535; (this is the case
on
> CW / PalmOS when you choose 16 bits ints)
>
> usually moving that to
> UInt32 SPECIAL_VALUE = (UInt32)-1L;
> is better. At least, it will work on most known actual platforms.
>
> (notice the L which means long, so long representation which is 32 bits at
> least on nearly all platforms I know)
>
> it is yet non absolutely reliable, but the better I think.
>
> Wish it helps.
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
>
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to