Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zcc: not support modificator order "const static" instead "static const" #2335

Open
RodrigoDornelles opened this issue Jun 30, 2023 · 0 comments

Comments

@RodrigoDornelles
Copy link

I know that the correct thing is to always put "static" before "const", but until today, no compiler I've seen is strict about this.

a suggestion, you can either allow it, leave a friendlier error message, or ignore it.

Not of great importance to made lexer more complex, I believe.

primitive

code

const static int z = 5;

error

teste.c:7:14: error: Missing token, expecting ( got i
teste.c:7:20: error: Illegal Argument Name: 
teste.c:7:22: error: Illegal Argument Name: 
teste.c:7:23: error: Illegal Argument Name: 
teste.c:10:1: error: Illegal Argument Name: 
teste.c:11:11: error: Illegal Argument Name: 
teste.c:11:22: error: Illegal Argument Name: 
teste.c:11:25: error: Illegal Argument Name: 
teste.c:12:8: error: Illegal Argument Name: 
teste.c:12:9: error: Illegal Argument Name: 

Maximum (10) number of errors reached, aborting!
Compilation aborted

array of function pointers

code

const static void (*bar[])() = {foo, foo, foo};

error

teste.c:6:14: error: Missing token, expecting ( got v
teste.c:6:30: error: Illegal Argument Name: 
teste.c:6:41: fatal error: A parameter named foo (argument 3) has already been defined for function
Compilation aborted

the correct way

always to start with the location modifier, this is even more standard.

static const void (*bar[])() = {foo, foo, foo};
static const int z = 5;

🤠 have a great day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant