SHARE
TWEET

enum_confusion

chipant May 31st, 2020 785 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef enum __attribute__((__packed__)) {
  2.     GEN = 0,   
  3.     CYL
  4. } mCG;
  5.  
  6. mCG var1 = GEN;
  7.  
  8. int main(){
  9.   printf("%d\r\n", sizeof(var1));   // Prints : 1
  10.   printf("%d\r\n", sizeof(GEN));    // Prints : 4
  11.   printf("%d\r\n", sizeof(mCG));    // Prints : 1
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top