fork download
  1. #define LIST4(x, N) N<<(x), N<<((x)+1), N<<((x)+2), N<<((x)+3)
  2. #define LIST8(x, N) LIST4(x, N), LIST4(x+4, N)
  3. #define LIST16(x, N) LIST8(x, N), LIST8(x+8, N)
  4. #define LIST32(x, N) LIST16(x, N), LIST16(x+16, N)
  5. #define LIST64(N) LIST32(0, N), LIST32(32, N)
  6.  
  7. const unsigned values[] = { LIST32(0, 1u) }; // angenommen unsigned hat 32-Bit. Suffix nicht vergessen!
  8.  
  9. #undef LIST4
  10. #undef LIST8
  11. #undef LIST16
  12. #undef LIST32
  13. #undef LIST64
  14.  
  15. #define DEF(N) \
  16.   const unsigned int VALUE##N = values[N];
  17.  
  18. DEF(0)
  19. DEF(1)
  20. DEF(2)
  21.  
  22. #undef DEF
  23.  
  24. #include <iostream>
  25.  
  26. int main()
  27. {
  28. std::cout << VALUE0 << ' ' << VALUE1 << ' ' << VALUE2;
  29. }
Success #stdin #stdout 0s 2684KB
stdin
Standard input is empty
stdout
1 2 4