[ECOS] structure size

Grant Edwards grante@visi.com
Mon Jan 5 16:06:00 GMT 2004

>     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

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

More information about the Ecos-discuss mailing list