【问题标题】:Subscripted value is neither array nor pointer error下标值既不是数组也不是指针错误
【发布时间】:2020-09-28 14:00:43
【问题描述】:

我在头文件(Variables.h)中有这个:

#ifndef VARIABLES_H
#define VARIABLES_H

#define NUM 99
#define BOOL 193
#define FLOAT 12

struct bools{
    char name[100];
    bool state;
}bool_dataPoints[BOOL];

struct floats{
    char name[100];
    float q;
}float_dataPoints[FLOAT];

struct nums{
    char name[100];
    unsigned int q;
}num_dataPoints[NUM];

...

我正在尝试使用此指令(位于单独的 C 文件中):

#include "xc.h"
#include <stdbool.h>       
#include <stdlib.h>
#include <stddef.h>
#include "Variables.h"
    
if(bool_dataPoints[147].state){//I_EStop

...

但我在“if”行代码中遇到了这个错误:

error: subscripted value is neither array nor pointer

【问题讨论】:

    标签: arrays pointers struct compiler-errors


    【解决方案1】:

    我想通了,我的原型/声明中的参数与我的实现中的参数不匹配。我没有包括参数数据类型。

    【讨论】:

      猜你喜欢
      • 2012-01-11
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多