我正在尝试编写飞行计算机。
关于这个错误的奇怪想法是:
此代码块完美运行:
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(){}
但是,当我添加另一个与该对象完全无关的函数时,会发生有关 PlaneStatus 对象的错误。
#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(){}
这是错误消息
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:UsersisatuAppDataLocalTemparduino_modified_sketch_56794sketch_jul01a.ino:67:13: note: suggested alternative: 'mpuIntStatus'
void manuer(PlaneStatus ms){
^~~~~~~~~~~
你们能帮我弄清楚这是为什么吗?
谢谢,感谢所有意见
注意:这些代码是可重现的,您只需复制粘贴即可。
供将来参考
我从另一个论坛得到了答案。问题出在Arduino IDE的自动原型生成上。
这就解决了问题。
void manuer(PlaneStatus ms);
void manuer(PlaneStatus ms) {
ms.pitch;
}