fork(1) download
  1. #include <stdio.h>
  2. #include <stdint.h>
  3.  
  4. #define foreach(a, b)\
  5. for(typeof(*(b)) * _shit_begin = (b), * _shit_end = ((_shit_begin) + sizeof((b))/sizeof(*(b))), * (a) = _shit_begin; (a) != _shit_end; ++(a))
  6.  
  7. int main(void) {
  8. {
  9. uint32_t vec[6][3] = {
  10. {10, 11, 12},
  11. {20, 21, 22},
  12. {30, 31, 32},
  13. {40, 41, 42},
  14. {50, 51, 52},
  15. {60, 61, 62},
  16. };
  17. foreach(it, vec[2])
  18. fprintf(stderr, "%u\n", *it);
  19. }
  20. {
  21. uint32_t vec[] = {0, 1, 2, 3, 4, 5};
  22. foreach(it, vec)
  23. fprintf(stderr, "%u\n", *it);
  24. }
  25. {
  26. uint8_t vec[] = {0, 1, 2, 3, 4, 5};
  27. foreach(it, vec)
  28. fprintf(stderr, "%u\n", *it);
  29. }
  30. {
  31. uint64_t vec[] = {0, 1, 2, 3, 4, 5};
  32. foreach(it, vec)
  33. fprintf(stderr, "%lu\n", *it);
  34. }
  35. return 0;
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:17:3: error: implicit declaration of function ‘typeof’ [-Werror=implicit-function-declaration]
prog.c:17:3: error: ‘_shit_begin’ undeclared (first use in this function)
prog.c:17:3: note: each undeclared identifier is reported only once for each function it appears in
prog.c:17:3: error: ‘_shit_end’ undeclared (first use in this function)
prog.c:17:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:17:3: error: ‘it’ undeclared (first use in this function)
prog.c:17:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:22:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:22:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:27:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:27:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:32:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
prog.c:32:3: error: left-hand operand of comma expression has no effect [-Werror=unused-value]
cc1: all warnings being treated as errors
stdout
Standard output is empty