This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to align but with offset

Say I need to allocate struct A but b needs to be 4 aligned.

struct A
{
    char a;
    char b[42];
};

I guess I can manually pad a pointer returned by malloc(). Any cleaner way? Like gcc's __attribute__((aligned(4))) but that aligns the whole structure. And I can't change it's layout.