struct AA {
float a;
float b;
unsignedchar metadata;
};
The size of this are 4+4+1 , isn't it ?
AA *aa = new AA;
sizeof *aa = 12 ?????
I have read something like
your compiler may have a "#pragma option" feature that you can use to
wrap your structure definition, to enforce the byte alignment you want
You have to refer to your documentation for details.
Memory that is aligned on a 4-byte boundary may be faster to access, so as an optimization the compiler pads the structure size (and possibly members within the structure) to be on 4-byte boundaries.
You can turn that optimization off my changing your compiler settings or with #pragmas, but there's not really any reason to. It's not like losing 3 bytes is significant.