title: Some questions about a single-instance array in typedef
body: <p>I was perusing some code using arbitrary-length integers using the GNU Multi-Precision (GMP) library code.  The type for a MP integer is <code>mpz_t</code> as defined in gmp.h header file.</p>
  
  <p>But, I've some questions about the lower-level definition of this library-defined <code>mpz_t</code> type.  In the header code:</p>
  
  <pre><code>/* THIS IS FROM THE GNU MP LIBRARY gmp.h HEADER FILE */
  typedef struct
  {
      /* SOME OTHER STUFF HERE */
  } __mpz_struct;
  
  typedef __mpz_struct mpz_t[1];
  </code></pre>
  
  <p>First question:  Does the <code>[1]</code> associate with the <code>__mpz_struct</code>?  In other words, is the <code>typedef</code> defining a <code>mpz_t</code> type as a <code>__mpz_struct</code> array with one occurrence?</p>
  
  <p>Second question: Why the array? (And why only one occurrence?)  Is this one of those <a href="http://c2.com/cgi/wiki?StructHack" rel="noreferrer">struct hacks</a> I've heard about?</p>
  
  <p>Third question (perhaps indirectly related to second question):  The GMP documentation for the <code>mpz_init_set(mpz_t, unsigned long int)</code> function says to use it as pass-by-value only, although one would <em>assume</em> that this function would be modifying its contents within the called function (and thus would need pass-by-reference) syntax.  Refer to my code:</p>
  
  <pre><code>/* FROM MY CODE */
  mpz_t fact_val;                /* declaration */
  mpz_init_set_ui(fact_val, 1);  /* Initialize fact_val */
  </code></pre>
  
  <p>Does the single-occurrence array enable pass-by-reference automatically (due to the breakdown of array/pointer semantics in C)?  I freely admit I'm kinda over-analyzing this, but I'd certainly love any discussion on this.  Thanks!</p>