FWIW, there are lots of subtle (and not so subtle) differences with the
implementation of 'standard' data types when you move between processors
and compilers.  The size of 'int' and 'enum' are pretty obvious, but how
about the behavior of 'char' in mathematical computations?

The almost universal assumption is that 'char' is signed.  However, lots
of cross compilers for the embedded systems market allow 'char' to be
unsigned - by default!  I encountered this again recently while porting
a protocol stack I had originally written for M680x0 to an MPC860.  I
was blowing up after incoming packets were decoded from a HDLC bit
stream.  Some fields in the packet where 1 byte in size, I was treating
them as chars...  I didn't see the problem until I single stepped in
assembly.

To change the compile options I would have either had to treat the
protocol stack as a special case or universally changed the compiler
settings.  One would require a lot of typing and mucking with the build,
the other would run the risk of breaking something else in the project.

Changing the declarations in my files would have also been a lot of
typing (about 40 source files).  And, of course, every time you touch a
file you run the risk of breaking something...

Fortunately.  I had not used 'char', I had used a portable type called
ICHAR.  I just had to change:

typedef char ICHAR

to:

typedef signed char ICHAR

Then rebuild everything.

Needless to say, I'm a big fan of portable types.  That's not to say
that I am thrilled with the PalmOS types.  I have plenty of complaints,
but I would not call them 'idiotic'.

Best Regards,
-jjf  

-----Original Message-----
From: Stringer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 02, 2000 7:09 AM
To: Palm Developer Forum
Subject: Palm OS 3.5 Types - "my vent"


The fact that it has been addressed many times before doesn't
make it any less idiotic.

For example 'Int16' seems identical to 'short'
'UInt16' seems identical to 'unsigned short'
'Int32' seems identical to 'long'
"UInt32' seems identical to 'unsigned long'

I know that using 'int' is sometimes risky because there's a compiler
flag (in MetroWerks) for 2 or 4 byte 'int's, but 'long' and 'short' are
very specific in size.  And there's a semi-implemented 'long long' for
8 byte integer variables.

[snip]

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to