~sircmpwn/annotate#16: 
Syntax error on a struct definition

You can see the issue at the end of this build log:

Scanning   1/1 libforks.c                Error libforks.c:108:19: syntax error
  0 symbols     0 references
Scan complete: 1 files, 0 symbols, 0 references, 0 orphan refs

Here is the line 108:

struct serv_Client {

The file is valid and builds nicely with both Clang and GCC. It’s standard C99, without any GNU extensions.

Status
REPORTED
Submitter
~moteta
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
lang-c

~mcf 2 years ago

I think this is due to how identifiers are handled in the lexer. Currently, if the identifier matches a type name, it always returns TYPEDEF_NAME, but depending on the context, this might not be correct.

Here are some examples that this breaks:

typedef struct A A;
struct A {int x;};
typedef int B;
void f(B *B);
typedef int C;
void f(void) {
	goto C;
C:;
}

See also https://en.wikipedia.org/wiki/The_lexer_hack

Register here or Log in to comment, or comment via email.