【问题标题】:typedef struct on Arduino : variable does not name a typeArduino上的typedef结构:变量没有命名类型
【发布时间】:2015-02-06 13:30:05
【问题描述】:

我想在 arduino mega 上为 20 个传感器制作一个 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;

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

错误:“探空仪”没有命名类型

错误:“测试”没有命名类型

【问题讨论】:

  • 错误,它显示sondesondes?此外,float valeurs[]; 必须在结尾(根据C99)。
  • @SouravGhosh 抱歉,这是“探空仪”

标签: c++ c struct arduino typedef


【解决方案1】:

您还没有提供完整的代码,所以只能猜测。

我怀疑问题在于以下语句:

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

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

【讨论】:

  • 为什么会这样?结构实体只能在函数内部分配?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-09
  • 1970-01-01
  • 1970-01-01
  • 2016-06-03
  • 2012-11-02
相关资源
最近更新 更多