I have problems with my (quite large) program... After the last round of modifications and additions, it doesn't compile any more.
It returns the following error:
137: error: expected unqualified-id before 'else'
Problems are:
the file is the top level of my project, but has not been changed
it contains mostly pins setup and the main loop
there is no "else" near line 137 (we are in the middle of input/output pins setup)
if I add an instruction like: i=0; in line 137 or 136, I get the same error at the same line
I have compared 2 versions before and after the error appeared, and could not find anything that looks suspicious (I added a new function, deleted/added a few things, but I did not find any obvious structural mistake).
Any idea?
Any good tool to check my program in another environment than the Arduino IDE?
Do a CTRL-T, see if you have mismatched number of ( )s or { }, that is usually the culprit. Or a ; got deleted somewhere, or you're missing a , in a list of elements in an array. It will be some kind of typo like that.
Let's necro this thread, maybe it helps somebody. Encountered same problem and braces structure WAS correct, still was complaining about "else if". Spent an hour on it and finally found out boolean was the culprit.
bool var1 = true;
bool var2 = true;
// This doesn't compile:
if (var1) {
// ...
} else if (var2) {
// ...
}
// This does:
if (true == var1) {
// ...
} else if (true == var2) {
// ...
}
So a boolean value itself doesn't work, but comparison does. Well, I use mostly high level languages now, but I can't remember C would not allow for standalone boolean expression in else if (...). Am I just stupid? Or what trickery is this?