title: Can a function prototype typedef be used in function definitions?
body: <p>I have a series of functions with the same prototype, say</p>
  
  <pre><code>int func1(int a, int b) {
    // ...
  }
  int func2(int a, int b) {
    // ...
  }
  // ...
  </code></pre>
  
  <p>Now, I want to simplify their definition and declaration. Of course I could use a macro like that:</p>
  
  <pre><code>#define SP_FUNC(name) int name(int a, int b)
  </code></pre>
  
  <p>But I'd like to keep it in C, so I tried to use the storage specifier <code>typedef</code> for this:</p>
  
  <pre><code>typedef int SpFunc(int a, int b);
  </code></pre>
  
  <p>This seems to work fine for the declaration:</p>
  
  <pre><code>SpFunc func1; // compiles
  </code></pre>
  
  <p>but not for the definition:</p>
  
  <pre><code>SpFunc func1 {
    // ...
  }
  </code></pre>
  
  <p>which gives me the following error:</p>
  
  <pre><code>error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
  </code></pre>
  
  <p>Is there a way to do this correctly or is it impossible?
  To my understanding of C this should work, but it doesn't. Why?</p>
  
  <hr>
  
  <p>Note, gcc understands what I am trying to do, because, if I write</p>
  
  <pre><code>SpFunc func1 = { /* ... */ }
  </code></pre>
  
  <p>it tells me</p>
  
  <pre><code>error: function 'func1' is initialized like a variable
  </code></pre>
  
  <p>Which means that gcc understands that SpFunc is a function type.</p>