>
>
> Hi there - over on the gtk-app-devel list, Tor Lillqvist and I were
> discussing the compiler flag -mms-bitfields. When building a
> gtk-win32 app,
> this is needed to ensure that structs will be aligned to the
> traditional
> Microsoft (8-byte) alignment standard.
>
No, 8-byte structure packing is default on mingw32
-mms-bitfields is much more specific
It is explained in gcc.info.
<quote>
MSVC interprets zero-length bitfields in the following ways:
1. If a zero-length bitfield is inserted between two bitfields
that would normally be coalesced, the bitfields will not be
coalesced.
For example:
struct
{
unsigned long bf_1 : 12;
unsigned long : 0;
unsigned long bf_2 : 12;
} t1;
The size of `t1' would be 8 bytes with the zero-length
bitfield. If the zero-length bitfield were removed, `t1''s
size would be 4 bytes.
2. If a zero-length bitfield is inserted after a bitfield,
`foo', and the alignment of the zero-length bitfield is
greater than the member that follows it, `bar', `bar' will be
aligned as the type of the zero-length bitfield.
For example:
struct
{
char foo : 4;
short : 0;
char bar;
} t2;
struct
{
char foo : 4;
short : 0;
double bar;
} t3;
For `t2', `bar' will be placed at offset 2, rather than
offset 1. Accordingly, the size of `t2' will be 4. For
`t3', the zero-length bitfield will not affect the alignment
of `bar' or, as a result, the size of the structure.
Taking this into account, it is important to note the
following:
1. If a zero-length bitfield follows a normal bitfield, the
type of the zero-length bitfield may affect the
alignment of the structure as whole. For example, `t2'
has a size of 4 bytes, since the zero-length bitfield
follows a normal bitfield, and is of type short.
2. Even if a zero-length bitfield is not followed by a
normal bitfield, it may still affect the alignment of
the structure:
struct
{
char foo : 6;
long : 0;
} t4;
Here, `t4' will take up 4 bytes.
3. Zero-length bitfields following non-bitfield members are
ignored:
struct
{
char foo;
long : 0;
char bar;
} t5;
Here, `t5' will take up 2 bytes.
</quote>
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-
http://p.sf.net/sfu/adobe-com_______________________________________________
MinGW-users mailing list
[hidden email]
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.
Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming