fork download
  1. #include <stdio.h>
  2.  
  3. #define LIST_OF_ENUM_IDS \
  4.   X(A, 0) \
  5.   X(B, 1) \
  6.   X(C, 2) \
  7.   X(D, 4) \
  8.   X(E, 6) \
  9.   X(F, 8) \
  10.   X(G, 10)
  11.  
  12. #define X(id, val) \
  13.   id = val,
  14.  
  15. typedef enum
  16. {
  17. LIST_OF_ENUM_IDS
  18. } my_enum;
  19.  
  20. #undef X
  21.  
  22. #define X(id, val) id##_impl_helper,
  23.  
  24. enum my_enum_impl_helper__ {
  25. LIST_OF_ENUM_IDS
  26. MY_ENUM_MAX_ELEMENTS
  27. };
  28.  
  29. #undef X
  30.  
  31. int main(void) {
  32. printf("%d %d %d", A, G, MY_ENUM_MAX_ELEMENTS);
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 10320KB
stdin
Standard input is empty
stdout
0 10 7