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]
Other format: [Raw text]

Re: structure size


>     William> Although your answer is a 'better' solution in that
>     William> it gives a developer more power over individual
>     William> structures, I thought it would be interesting to turn it
>     William> on once for an entire module.
> 
> That is usually a bad idea. When you #include system headers
> you would be defining data structures laid out differently
> from how the rest of the system understands those structures.
> Those headers may also define inline functions which
> manipulate those structures, and things quickly get very
> messy.
> 
> Also, when the compiler inserts padding it usually does so for
> a good reason: manipulating packed structures can involve a
> significant performance penalty.

Not only that, on many systems (ARM, SPARC, H8, ...)
manipulating packed structures can cause bus faults (if you're
lucky) or silently produce incorrect results.

Be very, very careful when packing structs.  You can get bit.
Or more likely, somebody else will get bit in the future when
they try to figure out why your code stopped working...

-- 
Grant Edwards
grante@visi.com

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


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