You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"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.
The text was updated successfully, but these errors were encountered:
"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.
The text was updated successfully, but these errors were encountered: