Advertisement
teknoraver

enum_size

Nov 12th, 2020
922
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. enum e1 {
  4.     UNO = 1,
  5.     DUE = 2,
  6.     TRE = 3,
  7.     QUATTRO = 4,
  8. } __attribute__((packed));
  9.  
  10. enum e2 {
  11.     UNOB = 1,
  12.     DUEB = 2,
  13.     TREB = 3,
  14.     QUATTROB = 4,
  15. };
  16.  
  17. int main(int argc, char *argv[])
  18. {
  19.     enum e1 e1;
  20.     enum e2 e2;
  21.  
  22.     printf("e1: %lu\n", sizeof(e1));
  23.     printf("e2: %lu\n", sizeof(e2));
  24.  
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement