Multibyte paddings fine for some situations and I think all compliers for
these targets do it. However Im talking about receiving comms data as byte
streams, a different matter entirely

If a structure of words is recieved over a serial link as a byte stream then
you dont know if if the words are aligned or not.

You can either read it all as bytes and recombine it yourself - therefore
not being able to overlay a structure.
or see if the first byte is at an odd address and if so do a MemMove
(source_address+1,source_adress, len) to align it all.

Most compliers sort this out for you.

> -----Original Message-----
> From: Roger Chaplin [SMTP:[EMAIL PROTECTED]]
> Sent: 28 July 2000 15:56
> To:   Palm Developer Forum
> Subject:      RE: Compiler - Cannot convert signed char * to char *
> 
> Richard Anderson <[EMAIL PROTECTED]> wrote:
> 
> > On the pointer front:
> > 
> > I dont expect the compiler to change the pointer but take this 
> example
> > (psudo addresses):
> > 
> > I receive 3 bytes of serial data and place them at address 0x100
> > 
> > if my data is infact:
> > 
> >  struct {
> >     char a;
> >     word b;
> > } mystruct;
> > 
> > And I have a pointer to mystruct overlayed on my serial data
> > 
> > mystruct *ptr = 0x100;
> > 
> > and do :    word c = *mystruct->b       then you get a bus error as 
> the
> > compiler does a move.w over a odd boundary.
> > What it should do is 2 * move.b and recombine the result 
> transparently to
> > the C user. Other 68K compiler I have used do this.
> 
> Ah, okay. Are you sure about the two move.b instructions? Most 
> compilers I've seen that are targetted to architectures requiring even 
> address for multi-byte accesses accomplish such safety by adding a byte 
> of padding as necessary within structs, so that multi-byte elements are 
> on even addresses. There should be an option somewhere in the CW 
> settings to make it do this.
> 
> --
> Roger Chaplin
> <[EMAIL PROTECTED]>
> 
> -- 
> 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