我正在尝试编译我的代码。如果我在 Arduino IDE 中编译它可以工作,但如果我在 Visual Studio 2019 中尝试它会失败。
我正在尝试使用结构作为参数。
我试过指针和typedef
,但得到同样的错误
我可以在 Arduino IDE 中编译它,但相同的代码在 VS 2019 中出现此错误:
Compiling debug version of 'test' for 'ATmega2560 (Mega 2560) (Arduino Mega)' test.ino: 7:17: error: variable or field 'myFunction' declared void Error compiling project sources Debug build failed for project 'test' test.ino: 7:17: error: 'data' was not declared in this scope test.ino:7: note suggested alternative atan atan
struct data{
float data;
};
data data_struct;
void myFunction(data data_struct){
}
int main(){}
您没有为 myFunction 提供声明。这是由 Arduino IDE 在幕后完成的。
尝试:
struct data{
float data;
};
data data_struct;
void myFunction(data data_struct);
void myFunction(data data_struct){
}
int main(){}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句