title: CPP Macro: Counter that gives number of instantiations/calls
body: <p>I want to have a <strong>C</strong> preprocessor macro that knows the number of instantiations/macro calls of this macro so far.
  Example:</p>
  
  <pre><code>int main() {
    printf("%d\n", MACRO());
    printf("%d\n", MACRO());
  }
  </code></pre>
  
  <p>Should print</p>
  
  <pre><code>0
  1
  </code></pre>
  
  <p>Is something like this possible?</p>
  
  <p>Note that it is <strong>not</strong> enough to forward this to a function as proposed below.
  It should work in the following context:</p>
  
  <pre><code>// global variable
  std::vector&lt;bool&gt; calls_hit;
  
  #define OTHER_MACRO() \
  { \
      const int counter = MACRO(); \
      calls_hit.resize(std::max(calls_hit.size(), counter)); \
      calls_hit[counter] = true; \
  }
  </code></pre>