title: Array-size macro that rejects pointers
body: <p>The standard array-size macro that is often taught is</p>
  
  <pre><code>#define ARRAYSIZE(arr) (sizeof(arr) / sizeof(arr[0]))
  </code></pre>
  
  <p>or some equivalent formation. However, this kind of thing silently succeeds when a pointer is passed in, and gives results that can seem plausible at runtime until things mysteriously fall apart.</p>
  
  <p>It's all-too-easy to make this mistake: a function that has a local array variable is refactored, moving a bit of array manipulation into a new function called with the array as a parameter.</p>
  
  <p>So, the question is: is there a "sanitary" macro to detect misuse of the <code>ARRAYSIZE</code> macro in C, preferably at compile-time? In C++ we'd just use a template specialized for array arguments only; in C, it seems we'll need some way to distinguish arrays and pointers. (If I wanted to reject arrays, for instance, I'd just do e.g. <code>(arr=arr, ...)</code> because array assignment is illegal).</p>