Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arduino typedef声明中缺少类型名称_Arduino - Fatal编程技术网

Arduino typedef声明中缺少类型名称

Arduino typedef声明中缺少类型名称,arduino,Arduino,您好,有一个错误显示:每当我将代码上载到Arduino atmega时,typedef声明中缺少类型名称 typedef union DrsData { unsigned char ucData[MAX_PACKET_SIZE-MIN_PACKET_SIZE]; DrsRWData stRWData; DrsIJogData stIJogData; DrsSJogData stSJogData; <-the error is highlig

您好,有一个错误显示:每当我将代码上载到Arduino atmega时,typedef声明中缺少类型名称

typedef union DrsData
{
unsigned char   ucData[MAX_PACKET_SIZE-MIN_PACKET_SIZE];

 DrsRWData      stRWData;
 DrsIJogData        stIJogData;
 DrsSJogData        stSJogData; <-the error is highlighted at this line
}DrsData;

事情是这样的:ArduinoIDE的设计目的是让初学者更容易。不幸的是,用户定义的类型实际上使我们其他人的工作更加困难

链接页面建议将类型声明放在单独的头文件中。我还成功地运用了以下技术:

typedef struct _xyz {
    int a;
    int b;
    int c;
} XYZ;

void myFunc(struct _xyz *xyzName) {
    ...
}
将生成错误的行更改为
struct\u DrsSJogData stSJogData
应该解决这个错误(如果您也按照我的建议更改了DrsSJogData的声明),但是刚刚阅读了Arduino的建议,我会同意


将所有类型声明分别放在主草图的头文件中,这样就可以了。

您可以发布完整的源代码、包含的头以及完整的错误消息吗?
line 136: error: missing type-name in typedef-declaration
line 147: error: missing type-name in typedef-declaration
line 250: error: ISO C++ forbids declaration of 'unData' with no type
line 251: error: missing type-name in typedef-declaration
line 259: error: expected primary-expression before '.' token
typedef struct _xyz {
    int a;
    int b;
    int c;
} XYZ;

void myFunc(struct _xyz *xyzName) {
    ...
}