Topic: Various struct layouts: recommended practice
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/09/04 Raw View
[Note: this article is cross-posted. You can reply
to both group, or only to one group. Please keep
this note in all followups to both groups.]
Some compilers support various struct layouts:
- the fastest one
- the smallest one
- the MS one
- the ABI specified one
For ex. CodeWarrior let the user choose that using a pragma,
the syntax look likes:
#pragma push alignment
#pragma align 68k
struct T_68K { int i; char c; };
#pragma align powerpc
struct T_PPC { int i; char c; };
#pragma pop alignment
T_68K has the preferred alignement for the 68000, etc
One could even imagine non conforming layouts,
where &x.c < &x.i...
What is the recommended way to manage that:
- pragmas:
- until C9X, aren't manageable via #ifdef
- aren't scoped: one needs push/pop commands
to save previous behaviour
- extern "language-convention" { declarations }
- C++ only
- intended to name a language (like C, FORTRAN),
not a precise ABI ("
- intended to apply to functions and
functions pointers only
- any others ?
--
Valentin Bonnard
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]