C 64-bit Pointer Alignment

Posted by DuneBug on Stack Overflow See other posts from Stack Overflow or by DuneBug
Published on 2010-03-24T07:10:27Z Indexed on 2010/03/24 7:13 UTC
Read the original article Hit count: 246

Filed under:
|
|

Are pointers on a 64-bit system still 4 byte aligned (similar to a double on a 32 bit system)? Or are they note 8 byte aligned?

For example, on a 64-bit system how big is the following data structure:

struct a {
    void* ptr;
    char myChar;
}

Would the pointer by 8 byte aligned, causing 7 bytes of padding for the character (total = 8 + 8 = 16)? Or would the pointer be 4 byte aligned (4 bytes + 4 bytes) causing 3 bytes of padding (total = 4 + 4 + 4 = 12)?

Thanks, Ryan

© Stack Overflow or respective owner

Related posts about c

    Related posts about alignment