This is the mail archive of the
mailing list for the eCos project.
Re: structure size
>>>>> "William" == William Martin <firstname.lastname@example.org> writes:
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. Programmers should be aware of this and only pack
structures when absolutely necessary. A per-structure attribute
William> so...Are pragma's supported? Specifically, #pragma pack
William> I looked at the documentation page (preprocessor
William> directives, pragmas..etc) and checked the archive, but
William> only found one post related to pragmas and packing.
In general the gcc developers don't like #pragma, and for good
reasons. The interpretation of any #pragma is specific to each
compiler. When you start inserting pragmas the source code is now tied
to one specific compiler rather than portable. The usual way to handle
such portability issues is by preprocessor #define's, but you cannot
wrap a #pragma inside a #define. Attributes are different, you can
define suitable macros for those. There is some more info on this in
the gcc documentation, see the section on Declaring Attributes of
Bart Veer eCos Configuration Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss