简体   繁体   English

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

[英]typedef struct on Arduino : variable does not name a type

I want to make a typedef struct ( or similar, if i can't ) on arduino mega for 20 sensors, but i have a error and i don't understand why. 我想在arduino mega上为20个传感器制作一个typedef struct (或者类似的,如果我不能),但是我有一个错误,我不明白为什么。 Is it from arduino compilation or from my code ? 是来自arduino编译还是来自我的代码? Do you think that i must to put my code on a header file ? 您是否认为我必须将代码放在头文件中?

 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;

I have this error on the compilation : 我在编译时遇到此错误:

error: 'sondes' does not name a type 错误:“探空仪”未命名类型

error: 'test' does not name a type 错误:“测试”未命名类型

You have not provided your complete code, so it possible only to guess. 您尚未提供完整的代码,因此只能猜测。

I suspect that the problem is that the statements: 我怀疑问题在于这些陈述:

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

are written in the body of the ino file, not inside a function. 是写在ino文件的主体中,而不是在函数内部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM