"Hans Leidekker" hans@it.vu.nl wrote:
[Use a fixed width font to view this message]
MSVC MinGW GCC
Alignment of __int64: 8 8 8 Size of __int64: 8 8 8
Alignment of large_int: 8 8 4 Size of large_int: 8 8 8
Alignment of container1: 8 8 4 Size of container1: 16 16 12
Alignment of container2: 8 8 4 Size of container2: 16 16 12
Alignment of container3: 8 8 4 Size of container3: 8 8 8
Clearly GCC is the odd one out. When a double is embedded in a structure GCC does not adjust the alignment of the structure to the size of a double.
So, should we add -malign-double to the compiler flags?
After another inspection of Wine's dlls/kernel/tests/generated.c I think that MSVC case was actually never tested!
Here is an example of the code:
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && defined(__cplusplus) # define FIELD_ALIGNMENT(type, field) __alignof(((type*)0)->field) #elif defined(__GNUC__) # define FIELD_ALIGNMENT(type, field) __alignof__(((type*)0)->field) #else /* FIXME: Not sure if is possible to do without compiler extension */ #endif
I don't know what version of MS cl.exe has _MSC_VER >= 1300, but one that comes with Visual Studio 6.0 has _MSC_VER set to 1200. Moreover, since the test is a .c file __cplusplus is never defined, therefore FIELD_ALIGNMENT is not defined by the above code and later in that file we have:
#ifdef FIELD_ALIGNMENT # define TEST_FIELD_ALIGNMENT(type, field, align) \ ok(FIELD_ALIGNMENT(type, field) == align, \ "FIELD_ALIGNMENT(" #type ", " #field ") == %d (expected " #align ")\n", \ FIELD_ALIGNMENT(type, field)) #else # define TEST_FIELD_ALIGNMENT(type, field, align) do { } while (0) #endif
i.e. FIELD_ALIGNMENT gets an empty definition. Same for _TYPE_ALIGNMENT.
Patrik, did you actually got it working with MS cl.exe?