views:

105

answers:

1

GCC likes to tell me that I'm missing a specifier-qualifier-list in its error messages.

I know that this means I didn't put in a correct type of something.

But what exactly is a specifier-qualifier-list?

Edit:

Example C code that causes this:

#include <stdio.h>

int main(int argc, char **argv) {
    struct { undefined_type *foo; } bar;
    printf("Hello, world!");
}

Gives these errors from GCC:

Lappy:code chpwn$ gcc test.c
test.c: In function ‘main’:
test.c:4: error: expected specifier-qualifier-list before ‘undefined_type’
+2  A: 

It's a list of specifiers and qualifiers :-) Specifiers are things like void, char, struct Foo, etc., and qualifiers are keywords like const and volatile. See this C grammar for the definition.

In your case, undefined_type was not defined yet, so the parser saw it as an identifier, not a specifier-qualifier-list like it expected. If you were to typedef ... undefined_type; before its occurrence, then undefined_type would become a specifier.

If you're thinking in terms of parsing C with a context-free grammar, the way the compiler handles typedefs and such may be bothersome. If I understand correctly, it games the parser generator does this by sneaking in symbol table operations so it can use context to parse the source code.

Joey Adams