title: Passing array literal as macro argument
body: <p>This has been bugging me for some time, for example, if I'm trying to write this code:</p>
  
  <pre><code>// find the length of an array
  #define ARRAY_LENGTH(arr) (sizeof(arr)/sizeof(int))   
  // declare an array together with a variable containing the array's length
  #define ARRAY(name, arr) int name[] = arr; size_t name##_length = ARRAY_LENGTH(name);
  
  int main() {
      ARRAY(myarr, {1, 2, 3});
  }
  </code></pre>
  
  <p>The code gives this error:</p>
  
  <pre><code>&lt;stdin&gt;:8:31: error: macro "ARRAY" passed 4 arguments, but takes just 2
  </code></pre>
  
  <p>Because it sees <code>ARRAY(myarr, {1, 2, 3});</code> as passing <code>ARRAY</code> the argument <code>myarr</code>, <code>{1</code>, <code>2</code>, and <code>3}</code>. Is there any way to pass an <em>array literal</em> to macros?</p>
  
  <p>EDIT: In some of the more complex macros I needed, I may also need to pass two or more arrays to the macro, so variadic macro does not work.</p>