This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: data alignment issues


What about with unions?  When I know damn well both platforms have the
same size for their primitive data types is it ok to copy an entire
union to the buffer?   After all, the union will only be the size of the
largest data type, and no alignment issues should happen right?

-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[mailto:ecos-discuss-owner@sources.redhat.com] On Behalf Of Andrew Lunn
Sent: Thursday, August 09, 2001 8:55 AM
To: Trenton D. Adams
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] data alignment issues


On Thu, Aug 09, 2001 at 08:43:03AM -0600, Trenton D. Adams wrote:
> Why not send structures if it works?  After all, if I've tested it and

> there isn't any problems, then it's no problem right?  Is there any 
> better way sending data?  I suppose I could send the structure one 
> field at a time

What you are say is that it works today with gcc verions X for the
target, and MSVC version Y for the host. New version of the compilers
may decide to layout the structures differently. Borland may do
something different. The next versions of gcc may do something
different. MS may change there compiler. At that point, you have to
maintain old versions of the tools so you can rebuild your application. 

What you should do is add some marshelling code. That takes the fields
from the structures and places them into an char * array at well known
addresses. You can easily write this in a partable way.

If you are not interested in portability, you can use the gcc
extensions.

        Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]