Why pragma pack does not work in here? sizeof() returning the size aligned to 4. I use compiler which comes with Microsoft Visual Studio 2015
#pragma pack(push,1)
struct Header {
uint16_t zero = 0;
uint32_t id{};
};
struct ImageBlock : Header {
uint32_t currentValidLength{};
};
#pragma pack(pop)
constexpr int sz = sizeof(ImageBlock); // returns 12 but should be 10
Tried to also set Struct member alignment (/Zp1) compiler option with no luck
Looks like it's an IntelliSense bug. At runtime, the size is correct, but Visual Studio shows me an incorrect value of
szwhile editing. I've also triedstatic_asserton the size: VS shows that it will fail at compile time, but in fact, everything is ok.