预期的说明符 – 限定符 – 列表之前
我有这个结构类型定义:
typedef struct { char *key; long canTag; long canSet; long allowMultiple; confType *next; } confType;
编译时,gcc会抛出此错误:
conf.c:6: error: expected specifier-qualifier-list before 'confType'
这是什么意思? 它似乎与此错误的其他问题无关。
您在声明之前使用了confType。 (下一个)。 相反,试试这个:
typedef struct confType { char *key; long canTag; long canSet; long allowMultiple; struct confType *next; } confType;
JoshD现在的回答是正确的,我通常会找到一个等价的变体:
typedef struct confType confType; struct confType { char *key; long canTag; long canSet; long allowMultiple; confType *next; };
当您只想公开不透明指针时,将typedef
放在头文件(接口)和源文件(实现)中的struct
声明中。