在Arduino IDE中,我可以创建具有自定义类型的变量,但不能从函数返回自定义类型:
这样编译
struct Timer
{
Timer()
{
}
};
Timer t;
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
int main()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这会产生Timer does not name a type
错误:
struct Timer
{
Timer()
{
}
};
Timer get_timer()
{
return Timer();
}
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
int main()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
两者都在Orwell Dev-Cpp中编译
我用MEGA-2560