Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bitfields_msvc
#include <iostream> #define be_smart typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; #ifdef be_smart enum MyEnum : u32 #else enum MyEnum : u8 #endif { MyEnum_Unknown = 0, MyEnum_CreationNotConfirmed, MyEnum_CreationConfirmed, MyEnum_DeletionNotConfirmed }; struct MyStruct { u64 handle; u16 firstWrittenIndex; u16 lastWrittenIndex; #ifdef be_smart enum MyEnum state : 8; #else enum MyEnum state; #endif u32 pendingInit : 1; u32 pendingDelete : 1; u32 pendingFlush : 1; u32 isFlushed : 1; u32 hasDirtyStates : 1; u32 hasModifiedMask : 1; u32 pendingNewBaseline : 1; u32 isStaticNetObject : 1; u32 countToNextBaseLine : 8; u32 pendingNewBaselineIndex : 4; }; int main() { u32 size = sizeof(MyStruct); u32 alignment = alignof(MyStruct); #ifdef be_smart printf("I'm smart!\n"); #endif printf("sizeof(MyStruct): %u, align %u", size, alignment); }
run
|
edit
|
history
|
help
0
lab1
Eight Queen
Matrix_1
auto decltype - Return Type Decltype
VS struct name enumerate
#21.2
base call virtual
not a parameter pack
Affine Key Finder and Decrypter
MSVC ignoring unknown attributes