structure alignment issues?
akcom
CppCoder at gmail.com
Wed May 31 17:21:19 PDT 2006
Translating the following from windows:
--- C Code:
#define IMAGE_SIZEOF_SHORT_NAME 8
typedef struct _IMAGE_SECTION_HEADER {
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union {
DWORD PhysicalAddress;
DWORD VirtualSize;
} Misc;
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
#define IMAGE_SIZEOF_SECTION_HEADER 40
--- D Code:
const uint IMAGE_SIZEOF_SHORT_NAME = 8;
const uint IMAGE_SIZEOF_SECTION_HEADER = 40;
align struct ImageSectionHeader
{
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union Misc
{
DWORD PhysicalAddress;
DWORD VirtualSize;
}
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
}
alias ImageSectionHeader IMAGE_SECTION_HEADER;
alias ImageSectionHeader *PIMAGE_SECTION_HEADER;
the problem is that ImageSectionHeader.sizeof == 36
Any ideas as to why?
More information about the Digitalmars-d-learn
mailing list