Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable or field '...' declared void Error on Ardunio Compiler

Tags:

c++

arduino

I am trying to code a flight computer.

The odd think about this error is:

This code block works flawlessly:

class PlaneStatus {
 public:
    PlaneStatus(double y, double p, double r, double t) {
      yaw = y;
      pitch = p;
      roll = r;
      throttle = t;
    }// Access specifier
    double yaw, pitch, roll, throttle;        // Attribute (int variable)     
};

void manuer(PlaneStatus ms){
  ms.pitch;
}

void setup(){}
void loop(){}

But when I add another function completely irrelevant to that object, an error about the PlaneStatus object occurs.

#include <Servo.h>
#include <Wire.h>

void driveServo(Servo servo, int trin ,int arg){
  servo.write(trin+ arg);
}

class PlaneStatus {
 public:
    PlaneStatus(double y, double p, double r, double t) {
      yaw = y;
      pitch = p;
      roll = r;
      throttle = t;
    }// Access specifier
    double yaw, pitch, roll, throttle;        // Attribute (int variable)     
};

void manuer(PlaneStatus ms){
  ms.pitch;
}

void setup(){}

void loop(){}

And this is the error message

sketch_jul01a:67:13: error: variable or field 'manuer' declared void

 void manuer(PlaneStatus ms){

             ^~~~~~~~~~~

sketch_jul01a:67:13: error: 'PlaneStatus' was not declared in this scope

C:\Users\isatu\AppData\Local\Temp\arduino_modified_sketch_56794\sketch_jul01a.ino:67:13: note: suggested alternative: 'mpuIntStatus'

 void manuer(PlaneStatus ms){

             ^~~~~~~~~~~

Can you guys help me figure out why is this?

Thank you and all input is appreciated

Note: Those codes are reproducible, you can just copy-paste.

like image 311
isa türk Avatar asked Oct 28 '25 05:10

isa türk


1 Answers

For future reference

I got an answer from another forum. The problem is with The Arduino IDE's auto-prototype generation.

This solves the problem.

void manuer(PlaneStatus ms);

void manuer(PlaneStatus ms) {
  ms.pitch;
}
like image 102
isa türk Avatar answered Oct 30 '25 20:10

isa türk