Structure and function with pointer for PID

Hi Everyone !

I am trying to compile this code which uses a structure and a function with a pointer for a PID controller.
The compiler says ''invalid use of incomplete type 'struct SPid' ".
I can not understand why it gives this error.
The program seems correct.

Thanks in advance for the help.

#include <stdio.h>

  struct { 
  double dState; // Last position input 
  double iState; // Integrator state 
  double iMax;
  double iMin; // Maximum and minimum allowable integrator state 
  double iGain; // integral gain 
  double pGain; // proportional gain 
  double dGain; // derivative gain 
}SPid;


void setup(){

  Serial.begin(9600);

};

void loop(){

}; 

double UpdatePID(struct SPid *pid, double error, double position) 
{ 
  double pTerm; 
  double dTerm; 
  double iTerm; 
  pTerm = pid->pGain * error; 
  // calculate the proportional term 
  // calculate the integral state with appropriate limiting 
  pid->iState += error; 
  if (pid->iState > pid->iMax) pid->iState = pid->iMax; 
  else if (pid->iState < pid->iMin) pid->iState = pid->iMin; 
  iTerm = pid->iGain * iState; // calculate the integral term 
  dTerm = pid->dGain * (position - pid->dState); 
  pid->dState = position; 
  return pTerm + iTerm - dTerm; 
}

Just two small changes and you will get the syntax right:

  struct SPid_t { 
  double dState; // Last position input 
  double iState; // Integrator state 
  double iMax;
  double iMin; // Maximum and minimum allowable integrator state 
  double iGain; // integral gain 
  double pGain; // proportional gain 
  double dGain; // derivative gain 
};
...
double UpdatePID(SPid_t *pid, double error, double position) 
...

Cheers!

Thanks a lot !