Go Down

Topic: Label related compiler error (Read 2 times) previous topic - next topic

mattallen37

Thanks, that does compile, but why would I need to do that (put a semi-colon after the colon)?
Quote
goto LABEL;
LABEL:;


Other than the file name, function name, and line number, the Arduino error messages are almost always useless, so I tend to disregard them.

PaulS

Quote
Thanks, that does compile, but why would I need to do that (put a semi-colon after the colon)?

Because a label introduces a block of code. You've got to have a block of code after the label. The block can be one line, which can have nothing but a semicolon on it.

Now, why, given that goto is not necessary, do you think you need to use it?

mattallen37

Okay, I guess that makes sense.

I don't think I need to use it. I was simply playing around, and ran into the error.

PeterH


And please do not talk about why labels are bad, or why I should not be using them.


They are bad, and you should not be using them.

As an aside, labels have to be associated with a statement and cannot be used in isolation; in your failing examples, there's no statement after the label.
I only provide help via the forum - please do not contact me for private consultancy.

mattallen37

I know that they aren't necessary, but sometimes it's fun to play around with them.

:smiley-roll: this is turning into what I explicitly stated I didn't want it to...

Go Up