Code Warrior Compiler bug?

2002-01-28 Thread Phong Nguyen
Thanks. The one you showed work! However, I still encounter the following problem: StrPrintF(msg, %02X, byCheckSum); Assuming byCheckSum = 0xB9 Instead of printing the string B9, it printed 00B9. Please let me know how to fix this problem. Thanks. --- Joe [EMAIL PROTECTED] wrote: ---

Re: Code Warrior Compiler bug?

2002-01-28 Thread Bob Withers
At 06:00 AM 1/28/2002 -0800, Phong Nguyen wrote: Thanks. The one you showed work! However, I still encounter the following problem: StrPrintF(msg, %02X, byCheckSum); Assuming byCheckSum = 0xB9 Instead of printing the string B9, it printed 00B9. Please let me know how to fix this problem.

Re: Code Warrior Compiler bug?

2002-01-28 Thread Max Bian
This shouldn't happen. The normal behavior in the case of 0NX, or 0Nd, or ... should be only 0-padded when the yielded string length is shorter than the precision N. Does it help if you force type conversion of byCheckSum with (UInt8)? Max --- Phong Nguyen [EMAIL PROTECTED] wrote: Thanks. The

Re: Code Warrior Compiler bug?

2002-01-28 Thread Phong Nguyen
Does it help if you force type conversion of byCheckSum with (UInt8)? Nop, it doesn't work with casting although byCheckSum has already been defined as Byte. Phong --- Max Bian [EMAIL PROTECTED] wrote: This shouldn't happen. The normal behavior in the case of 0NX, or 0Nd, or ... should

Re: Code Warrior Compiler bug?

2002-01-28 Thread Ben Combee
Max Bian [EMAIL PROTECTED] wrote in message news:74864@palm-dev-forum... This shouldn't happen. The normal behavior in the case of 0NX, or 0Nd, or ... should be only 0-padded when the yielded string length is shorter than the precision N. Does it help if you force type conversion of

Re: Code Warrior Compiler bug?

2002-01-28 Thread Max Bian
It is not, but... Isn't a good idea to have it behave just like others? Is there a POSIX standard (or other standard) that the most follow? Max --- Ben Combee [EMAIL PROTECTED] wrote: Remember that StrPrintF is not sprintf. It doesn't behave like the standard routine in several ways, the

Re: Code Warrior Compiler bug?

2002-01-28 Thread Dave Carrigan
Max Bian [EMAIL PROTECTED] writes: It is not, but... Isn't a good idea to have it behave just like others? Is there a POSIX standard (or other standard) that the most follow? The other side of that argument is that if it was supposed to behave like sprintf, it would have been named

Re: Code Warrior Compiler bug?

2002-01-28 Thread Phong Nguyen
I am tired of using the built-in functions in CodeWarrior. The book said that StrPrintF is equivalent to sprintf and that really screw me up when trying to port some of the existing and working codes in other platform into CodeWarrior. What I have had to do is rewriting several sections in the

Re: Code Warrior Compiler bug?

2002-01-28 Thread Joe
--- Phong Nguyen wrote: I am tired of using the built-in functions in CodeWarrior. The book said that StrPrintF is equivalent to sprintf and that really screw me up when trying to port some of the existing and working codes in other platform into CodeWarrior. What book says StrPrintF is

Re: Code Warrior Compiler bug?

2002-01-28 Thread Ben Combee
Phong Nguyen [EMAIL PROTECTED] wrote in message news:74927@palm-dev-forum... I am tired of using the built-in functions in CodeWarrior. The book said that StrPrintF is equivalent to sprintf and that really screw me up when trying to port some of the existing and working codes in other

Re: Code Warrior Compiler bug?

2002-01-27 Thread Marco Pantaleoni
On Sat, Jan 26, 2002 at 06:33:32PM -0800, Dave Carrigan wrote: Marco Pantaleoni [EMAIL PROTECTED] writes: Otherwise, as suggested by others, you can resort to #pragma to specify packed structures, but this is not portable and I'd tend to consider this one a bad programming practice. I

Re: Code Warrior Compiler bug?

2002-01-27 Thread Marco Pantaleoni
On Sat, Jan 26, 2002 at 02:33:49PM -, Laurence Mee wrote: To be properly portable, you would need a function that takes the byte stream and populated each of the structure's elements with the appropriate data (or writes the structure's elements back to the byte stream). However, I can't

Re: Code Warrior Compiler bug?

2002-01-26 Thread Atul Shingade
- Original Message - From: Phong Nguyen [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Sent: Saturday, January 26, 2002 9:29 AM Subject: Re: Code Warrior Compiler bug? What I want to do is: char buffer[100]; char* message = buffer; int index = 0; buildHeader (message

Re: Code Warrior Compiler bug?

2002-01-26 Thread Ben Combee
Phong Nguyen [EMAIL PROTECTED] wrote in message news:74740@palm-dev-forum... Thanks for the answers so far but if there is no solution for this issue, it would really be a SERIOUS problem for me and also for everyone out there when using the built-in function sizeof(..) !!! What can I

Re: Code Warrior Compiler bug?

2002-01-26 Thread Marco Pantaleoni
On Fri, Jan 25, 2002 at 07:59:18PM -0800, Phong Nguyen wrote: What I want to do is: char buffer[100]; char* message = buffer; int index = 0; buildHeader (message[index]); index += sizeof(HeaderType); assembleData (message[index]); index += 10; buildTrailer (message[index]); index +=

RE: Code Warrior Compiler bug?

2002-01-26 Thread Laurence Mee
more about design rather than trying to take short cuts. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Phong Nguyen Sent: 26 January 2002 03:59 To: Palm Developer Forum Subject: Re: Code Warrior Compiler bug? What I want to do is: char buffer[100]; char

Re: Code Warrior Compiler bug?

2002-01-26 Thread Dave Carrigan
Marco Pantaleoni [EMAIL PROTECTED] writes: Otherwise, as suggested by others, you can resort to #pragma to specify packed structures, but this is not portable and I'd tend to consider this one a bad programming practice. I think that it's a horrible programming practice, and should not be

Code Warrior Compiler bug?

2002-01-25 Thread Phong Nguyen
Hi, I define a structure as follows: typedef struct { Char name[2]; Char age; } InfoType; I expect that sizeof(InfoType) to be 3. However the compiler returned sizeof(InfoType) = 4 . Any suggestion? I guess that I have to change some of the compiler configuration but do not know

Re: Code Warrior Compiler bug?

2002-01-25 Thread Hal Mueller
Hint 1: try putting #pragma warn_padding on just before that definition. Hint 2: what is sizeof(InfoType) if you delete the Char name[2]? At 3:55 PM -0800 1/25/02, Phong Nguyen wrote: Hi, I define a structure as follows: typedef struct { Char name[2]; Char age; } InfoType; I

Re: Code Warrior Compiler bug?

2002-01-25 Thread Dave Carrigan
Phong Nguyen [EMAIL PROTECTED] writes: Hi, I define a structure as follows: typedef struct { Char name[2]; Char age; } InfoType; I expect that sizeof(InfoType) to be 3. However the compiler returned sizeof(InfoType) = 4 . Any suggestion? I guess that I have to

Re: Code Warrior Compiler bug?

2002-01-25 Thread Joe
--- Phong Nguyen wrote: I define a structure as follows: typedef struct { Char name[2]; Char age; } InfoType; I expect that sizeof(InfoType) to be 3. However the compiler returned sizeof(InfoType) = 4 . The processors currently used by Palm OS devices do not allow

Re: Code Warrior Compiler bug?

2002-01-25 Thread Keith Rollin
At 5:02 PM -0800 1/25/02, Joe wrote: --- Phong Nguyen wrote: I define a structure as follows: typedef struct { Char name[2]; Char age; } InfoType; I expect that sizeof(InfoType) to be 3. However the compiler returned sizeof(InfoType) = 4 . The processors currently

Re: Code Warrior Compiler bug?

2002-01-25 Thread Joe
I wrote: The processors currently used by Palm OS devices do not allow addressing of odd-numbered bytes, --- Keith Rollin wrote: Sure they do! How else would it access name[1]? Of course, Keith is right. What I meant is that variables must be aligned on an even boundry. Naturally, you

Re: Code Warrior Compiler bug?

2002-01-25 Thread Phong Nguyen
Thanks for the answers so far but if there is no solution for this issue, it would really be a SERIOUS problem for me and also for everyone out there when using the built-in function sizeof(..) !!! What can I do if I want to define several structure types defined a structure of a message and

Re: Code Warrior Compiler bug?

2002-01-25 Thread Max Bian
What exactly is the problem you have? Accessing the data in the MessageType struct? How is that a problem? Because sizeof() doesn't give you the size you expect? What structure pointers are you talking about? Max --- Phong Nguyen [EMAIL PROTECTED] wrote: Thanks for the answers so far but if

Re: Code Warrior Compiler bug?

2002-01-25 Thread Marco Pantaleoni
On Fri, Jan 25, 2002 at 06:50:53PM -0800, Joe wrote: I wrote: The processors currently used by Palm OS devices do not allow addressing of odd-numbered bytes, --- Keith Rollin wrote: Sure they do! How else would it access name[1]? Of course, Keith is right. What I meant is that

Re: Code Warrior Compiler bug?

2002-01-25 Thread Marco Pantaleoni
On Fri, Jan 25, 2002 at 07:12:47PM -0800, Phong Nguyen wrote: Thanks for the answers so far but if there is no solution for this issue, it would really be a SERIOUS problem for me and also for everyone out there when using the built-in function sizeof(..) !!! What can I do if I want to

RE: Code Warrior Compiler bug?

2002-01-25 Thread Laurence Mee
too sure how you are intending on using sizeof either - but there are always alternatives. Laurence Mee. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Phong Nguyen Sent: 26 January 2002 03:13 To: Palm Developer Forum Subject: Re: Code Warrior Compiler

Re: Code Warrior Compiler bug?

2002-01-25 Thread Marco Pantaleoni
On Sat, Jan 26, 2002 at 04:39:05AM +0100, Marco Pantaleoni wrote: You should really encode/decode your messages by manipulating sequences of bytes / words / dwords as needed. Remember also that when you encode/decode words and dwords in a way that is intended to be portable between

Re: Code Warrior Compiler bug?

2002-01-25 Thread Phong Nguyen
What I want to do is: char buffer[100]; char* message = buffer; int index = 0; buildHeader (message[index]); index += sizeof(HeaderType); assembleData (message[index]); index += 10; buildTrailer (message[index]); index += sizeof(TrailerType); and return index as the size of the built message.

Re: Code Warrior Compiler bug?

2002-01-25 Thread Joe
--- Phong Nguyen wrote: What I want to do is: char buffer[100]; char* message = buffer; int index = 0; buildHeader (message[index]); index += sizeof(HeaderType); assembleData (message[index]); index += 10; ... You haven't really explained why you want this, but assuming you must have