A good implication of big endian, you can type a creator with
WinDrawChars(&creator, 4, x, y). For a little endian you wouldn't
be able to do that. AFAIK, ARM is little endian, in this case
a lot of apps might need to be rewritten because of this issue.

As to StrPrintF it would be useless, if it was like you think.
POSE does it job perfectly well and shouldn't be confused with
byte order.

For file read, you might need byte conversion. A similar
problem is for networking where standard solution is htons and htonl.
It might have a Palm equivalent. You might use this if you want a generic 
solution.

M.



-----Original Message-----
From: Max Bian [mailto:[EMAIL PROTECTED]]
Sent: Monday, 17 December 2001 16:05
To: Palm Developer Forum
Subject: byte order


I just found out that palm use "Big Endian" while PCs use "little Endian". 
Maybe this explains why I got some weird values when I do formated printing
using StrPrintF, eg., when I pass a UInt32 to a "%d".  Are there other
concerns
about the byte orders in Palm programming?

One instance I can think of is when I work on file streams. If I have a file
stram that is an image of data file from a PC, I will runinto problem if I
expect a word to be read. I'll need to have the bytes converted.

FileRead(..., Int16 objSize, Int32 numObj, ...);

Now I have a question about the struct.  For example, I have the format:

typedef struct {
Int16 first;
Int32 second;
} MyStruct;

Is the first component stored at the low address or at high adress in Palm?

If I have the data of the struct written on PC to a file in one chunk with
fwrite: fwrite(..., sizeof(MyStruct), 1, ...);  

Then, I read the data from that FS on Palm with FileRead:
FileRead(..., sizeof(MyStruct), 1, ...);

What do I expect?  How do you guys deal with this sort of problems?

Thanks.

Max

__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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

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

Reply via email to