#include #ifdef _WIN32 # include # pragma pack(1) # define PACKED #else # define PACKED __attribute__((__packed__)) #endif class Test { public: Test() { #ifdef _WIN32 __writeeflags(__readeflags() | 0x40000); #else asm volatile("pushf \n" "pop %%rax \n" "or $0x40000, %%rax \n" "push %%rax \n" "popf \n" ::: "rax"); #endif int *p = (int *)&mystruct; *p = 1; printf("%i\n", *p); } private: char a; struct { char c1, c2; short s; } mystruct; } PACKED; int main(void) { new Test(); return 0; }