title: Is this the correct way to use va_arg with pointer to function?
body: <p>In a function like this:</p>
  
  <pre><code>typedef double(*dfun)(double);
  
  void tab(double x, int n, ...)
  {
      va_list args;
  
      va_start(args, n);
  
      printf("%5.2lf  \t", x);
  
      for (int i=0; i&lt;n; i++)
      {
          dfun tmp = va_arg(args, dfun);
  
          printf("  %5.2lf  \t", tmp(x));
      }
  
      va_end(args);
  }
  </code></pre>
  
  <p>Is it wrong if I pull the arguments like this:</p>
  
  <pre><code>    double(*tmp)(double) = va_arg(args, double(*)(double));
  </code></pre>
  
  <p>I came upon <a href="http://c-faq.com/varargs/funcptr.html" rel="nofollow">this</a> article which suggest a different approach if it doesn't work:</p>
  
  <blockquote>
    <p><strong>Q:</strong> I can't get va_arg to pull in an argument of type pointer-to-function. </p>
    
    <p><strong>A:</strong> Try using a typedef for the function pointer type. 
    The type-rewriting games which the va_arg macro typically plays are stymied by overly-complicated types such as pointer-to-function.</p>
  </blockquote>
  
  <p>In my case it works in both versions (GCC 5.2.1), that's why I was wondering is one approach better that the other? Is there some potential error when I don't typedef the pointer to function first?</p>