fork download
  1. #include <iostream>
  2.  
  3. #define ADD_TEST(X) do { results[i++] = (X); (void)__COUNTER__; } while (0)
  4.  
  5. const int foo_start = __COUNTER__;
  6. void foo(int *results) {
  7. int i = 0;
  8. ADD_TEST(100);
  9. ADD_TEST(200);
  10. ADD_TEST(300);
  11. }
  12. const int foo_end = __COUNTER__;
  13.  
  14. int main() {
  15. int results[foo_end - foo_start - 1];
  16. foo(results);
  17. for (int i : results) {
  18. std::cout << i << '\n';
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
100
200
300