title: va_arg with pointers
body: <p>I want to initialize a linked list with pointer arguments like so:</p>
  
  <pre><code>/* 
   * Initialize a linked list using variadic arguments
   * Returns the number of structures initialized
   */
  int init_structures(struct structure *first, ...) 
  {
      struct structure *s;
      unsigned int count = 0;
      va_list va;
      va_start(va, first);
  
      for (s = first; s != NULL; s = va_arg(va, (struct structure *))) {
          if ((s = malloc(sizeof(struct structure))) == NULL) {
              perror("malloc");
              exit(EXIT_FAILURE);
          }
          count++;
      }
  
      va_end(va);
  
      return count;
  }
  </code></pre>
  
  <p>The problem is that clang errors <code>type name requires a specifier or qualifier</code> at <code>va_arg(va, (struct structure *))</code>, and says that the type specifier defaults to int. It also notes instantiated form at <code>(struct structure *)</code> and <code>struct structure *</code>. This, what seems to be getting assigned to <code>s</code> is <code>int (struct structure *)</code>.</p>
  
  <p>It compiles fine when parentheses are removed from <code>(struct structure *)</code>, but the structures that are supposed to be initialized are inaccessible.</p>
  
  <p>Why is <code>int</code> assumed when parentheses are around the type argument passed to va_arg? How can I fix this?</p>