Skip to content

"register" is not highlighted as a keyword, and the compiler gives a cryptic error #1154

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

Closed
adzenith opened this issue Dec 6, 2012 · 2 comments
Labels
Component: IDE The Arduino IDE

Comments

@adzenith
Copy link

adzenith commented Dec 6, 2012

"register" is a keyword in C++, so using it as a variable name doesn't work. However, Arduino doesn't give much indication that this is the case: it doesn't highlight the word, and the compiler message is opaque.

Example code:
void foo(int register) {
Serial.write(register);
}

Error:
sketch_dec06b.ino: In function 'void foo(int)':
sketch_dec06b:2: error: expected primary-expression before 'register'

Note that the error doesn't come until the Serial.write line, because the compiler views the "int register" as a nameless argument of type "int register", rather than an attempt at making an int variable named "register". This makes debugging very confusing.

I think an easy fix would be to highlight the word "register"; ultimately, it would be nice if the compiler could spit out a nicer error in this case.

@cmaglie
Copy link
Member

cmaglie commented Dec 10, 2012

Thank you, I've added "register" as a keyword.
I see no reason adding a custom error message, the other keywords doesn't have it!

@adzenith
Copy link
Author

Thanks!

oriregev pushed a commit to oriregev/Arduino that referenced this issue Dec 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE
Projects
None yet
Development

No branches or pull requests

2 participants