title: Is this forward declaration of a function pointer valid in C?
body: <p>I am trying to find out if the following forward declaration is valid in ANSI-C:</p>
  
  <p>First file:</p>
  
  <pre><code>extern void * fptr;   // opaque forward declaration.
  int main (void) {
    fptr = NULL;        // set the function pointer to NULL
  }
  </code></pre>
  
  <p>Second file:</p>
  
  <pre><code>typedef int (*fptr_t)(int);
  fptr_t fptr;         // real declaration of the function pointer
  </code></pre>
  
  <p>To me, this should be invalid since <code>fptr</code> if declared with two different types, but neither <code>gcc</code> nor <code>clang</code> gives any warning.</p>
  
  <p>I would be more specifically interested in precise points of the C11 standard that allow to conclude why it is valid (or invalid).</p>
  
  <hr>
  
  <p>EDIT: in the C11 standard,6.2.7:2 says:</p>
  
  <blockquote>
    <p>All declarations that refer to the same object or function shall have
    compatible type; otherwise, the behavior is undefined.</p>
  </blockquote>
  
  <p>But I cannot find how to decide if <code>void*</code> is compatible with <code>fptr_t</code>.</p>