Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected specifier-qualifier-list before

Tags:

c

I have this struct type definition:

typedef struct {
    char *key;
    long canTag;
    long canSet;
    long allowMultiple;
    confType *next;
} confType;

When compiling, gcc throws this error:

conf.c:6: error: expected specifier-qualifier-list before ‘confType’

What does this mean? It doesn't seem related to other questions with this error.

like image 694
Delan Azabani Avatar asked Oct 08 '10 07:10

Delan Azabani


2 Answers

You used confType before you declared it. (for next). Instead, try this:

typedef struct confType {
    char *key;
    long canTag;
    long canSet;
    long allowMultiple;
    struct confType *next;
} confType;
like image 66
JoshD Avatar answered Nov 05 '22 19:11

JoshD


JoshD's answer now is correct, I usually go for an equivalent variant:

typedef struct confType confType;

struct confType {
    char *key;
    long canTag;
    long canSet;
    long allowMultiple;
    confType *next;
};

When you only want to expose opaque pointers, you put the typedef in your header file (interface) and the struct declaration in your source file (implementation).

like image 34
schot Avatar answered Nov 05 '22 18:11

schot