"does not name a type" Problem

 struct kalman_state
{
  int q; //process noise covariance
  int r; //measurement noise covariance
  int x; //value
  int p; //estimation error covariance
  int k; //kalman gain
} ;
kalman_state
kalman_init(double q, double r, double p, double intial_value)
{
  kalman_state result;
  result.q = q;
  result.r = r;
  result.p = p;
  result.x = intial_value;

  return result;
}


void setup()
{
}



void loop()
{

}

I have this code in arduino, while it reports error by saying that "ACC-kalman_filter.ino:2: error: 'kalman_state' does not name a type
'kalman_state' does not name a type"

May I know how to fix this

tks a lot

Simplest way, add a prototype above your function so the IDE does not generate one above the class (where it isn't defined yet).

An explanation what is happening: What does the IDE change in my sketch

struct kalman_state
{
  int q; //process noise covariance
  int r; //measurement noise covariance
  int x; //value
  int p; //estimation error covariance
  int k; //kalman gain
} ;

kalman_state kalman_init(double q, double r, double p, double intial_value);

kalman_state kalman_init(double q, double r, double p, double intial_value)
{
  kalman_state result;
  result.q = q;
  result.r = r;
  result.p = p;
  result.x = intial_value;
 
  return result;
}

void setup()
{
}

void loop()
{}

oh thanks that works