At 09:46 AM 9/6/2002 +0200, you wrote:
>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.

You could #include <limits.h>, then use the standard C constant ULONG_MAX, 
which will always be defined as the largest unsigned long.  Since 
CodeWarrior for Palm OS V8 supports a large part of the C99 standard, you 
could #include <stdint.h>, then use the constant UINT16_MAX for a UInt16, 
or UINT32_MAX for a UInt32.

Note, limits.h and stdint.h are headers that are part of the "freestanding" 
set dictated by the standard.  CW for Palm OS tries to adhere to the 
freestanding definition of the standard as far as library support is 
concerned, with some of the rest of the standard library implemented, but 
not a full "hosted" standard library.  The freestanding headers tend to be 
ones that describe the compiler and its environment, but don't provide 
additional functionality.

-- 
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com


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

Reply via email to