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’
It’s a list of specifiers and qualifiers 🙂 Specifiers are things like
void,char,struct Foo, etc., and qualifiers are keywords likeconstandvolatile. See this C grammar for the definition.In your case,
undefined_typewas not defined yet, so the parser saw it as an identifier, not a specifier-qualifier-list like it expected. If you were totypedef ... undefined_type;before its occurrence, thenundefined_typewould become a specifier.If you think 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 by sneaking in symbol table operations so it can use context to parse the source code.