Arduino上的typedef结构:变量没有命名类型

时间:2015-02-06 13:30:05

标签: c++ c struct arduino typedef

我想在20个传感器的arduino mega上制作一个typedef struct(或类似,如果我不能),但我有一个错误,我不明白为什么。它是来自arduino编译还是来自我的代码?你认为我必须将我的代码放在头文件上吗?

 typedef struct {
          char nom[8]; 
          int pin; 
          int onOff; 
          int pente;
          int offset;
          int maximun;
          int minimum;
          int constante1;
          int constante2;
          int hyst1;
          int hyst2;
          float moyenne; 
          float valeurs[]; 
          int frequence; 
        } structSondes;

    structSondes sondes[20];
    structSondes test;
    sondes[0].pin=1;
    test.pin=1;

我在编译时遇到这个错误:

  

错误:'sondes'没有命名类型

     

错误:'test'没有命名类型

1 个答案:

答案 0 :(得分:4)

您尚未提供完整的代码,因此只能猜测。

我怀疑问题在于陈述:

 sondes[0].pin=1;
 test.pin=1;

写在ino文件的正文中,而不是在函数内部。

相关问题