title: error: 'type name' declared as function returning a function
body: <p>I'm developing a small library for a PID controller using avr-gcc.In spite of declaring the function in the header file and defining it separately in a .c file the compiler is throwing the following errors:</p>
  
  <pre><code>Compiling C: pid.c
  avr-gcc -c -mmcu=atmega16 -I. -gdwarf-2 -DF_CPU=1000000UL -Os -funsigned-char -                 
  funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-  
  adhlns=./pid.lst  -std=gnu99 -MMD -MP -MF .dep/pid.o.d pid.c -o pid.o 
  pid.c:5: error: expected declaration specifiers or '...' before '(' token
  pid.c:5: warning: function declaration isn't a prototype
  pid.c:5: error: 'type name' declared as function returning a function
  pid.c:5: error: conflicting types for 'PID_init'
  pid.h:23: error: previous declaration of 'PID_init' was here
  pid.c: In function 'PID_init':
  pid.c:5: error: parameter name omitted
  </code></pre>
  
  <p>The header file contents of pid.h are as follows:</p>
  
  <pre><code>#include&lt;avr/io.h&gt;
  #include&lt;util/delay.h&gt;
  
  #ifndef PID_CONTROLLER
  #define PID_CONTROLLER
  struct PIDCONTROL
  
  {
  
  float error;
  float prev_error;
  float Kp;
  float Ki;
  float Kd;                       
  float pid;
  float P;
  float I;
  float D;
  float setpoint;
  
  };
  
  void PID_init(float,float,float,float,struct PIDCONTROL*);
  
  float PID(float,struct PIDCONTROL*);                        
  
  #endif
  </code></pre>
  
  <p>The definitions for the declared functions have been made in pid.c which contains the code shown below:</p>
  
  <pre><code>#include&lt;avr/io.h&gt;
  #include&lt;util/delay.h&gt;
  #include "pid.h"
  
  void PID_init(float SP,float Kp,float Ki,float Kd,struct PIDCONTROL *a)
  
  {
  
  a-&gt;Kp=Kp;
  
  a-&gt;Ki=Ki;
  
  a-&gt;Kd=Kd;
  
  a-&gt;pid=0;
  
  a-&gt;setpoint=SP;
  
  a-&gt;prev_error=0;
  
  }
  
  
  float PID(float PV,struct PIDCONTROL *a)
  
  {
  
  a-&gt;error=(a-&gt;setpoint)-PV;
  
  a-&gt;P=(a-&gt;Kp)*(a-&gt;error);
  
  (a-&gt;I)+=(a-&gt;Ki)*(a-&gt;error)*1.024;
  
  a-&gt;D=(a-&gt;Kd)*((a-&gt;error)-(a-&gt;prev_error))/1.024;
  
  a-&gt;pid=(a-&gt;P)+(a-&gt;I)+(a-&gt;D);
  
  a-&gt;prev_error=a-&gt;error;
  
  return(a-&gt;pid);
  
  }
  </code></pre>
  
  <p>I couldn't just figure out what's wrong with the code. Any help is appreciated.Thanks in advance.</p>