【发布时间】:2012-11-13 08:06:48
【问题描述】:
我正在尝试运行一个使用包含伺服对象的结构的 arduino 程序,它给了我这个错误:
error: 'leg' does not name a type
我认为我在内存管理方面做错了,但我对此相当陌生,因此感谢任何帮助。
这是我的代码:
#include <Servo.h>
typedef struct{
Servo hip;
Servo shin;
Servo foot;
}leg;
int currentPin = 0; //this is the pin that the leg will be attached to
leg getLeg(void){
leg newLeg;
newLeg.hip.attach(currentPin++);
newLeg.shin.attach(currentPin++);
newLeg.foot.attach(currentPin++);
return newLeg;
}
void setup()
{
leg frontLeft = getLeg();
leg frontRight = getLeg();
leg backRight = getLeg();
leg backLeft = getLeg();
}
void loop()
{
}
【问题讨论】:
-
“struct_Name”出现在哪里?
-
我试图概括错误,现在应该更清楚了。
标签: c memory-management struct arduino