title: Find out size of array in C with Macro
body: <p>I have trouble understanding if this macro does what it should. It is in a third party dll I am wrapping. </p>
  
  <pre><code>#ifdef __cplusplus
  #define NULL    0
  #else
  #define NULL    ((void *)0)
  #endif
  #define GTO_ARG_SIZE(arg) (long)((arg)==NULL ? 0 : (long)(arg)[0])
  </code></pre>
  
  <p>It is supposed to give the length of arg where arg is in my case a long*. It just points to a long but the Macro is also used when arg is an array of longs...</p>
  
  <p>From my understanding it returns the value at arg[0] if the pointer isn't NULL. But for when arg points to a long, it returns the value of the long, not the size of arg (1)...</p>
  
  <p>RESOLVED:</p>
  
  <p>Like many of you said, the mythical structure contains it's size as the first element. Sorry I have no documentation on the dll so I figured out only after digging a bit into the code. I was wondering at first if I really knew so little about C/C++.
  Thanks all</p>