Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22031

How to align but with offset

$
0
0

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.


Viewing all articles
Browse latest Browse all 22031

Trending Articles