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