Code Composer Error after while (1)

Thread Starter

em_cardc

Joined Apr 5, 2016
43
Can someone please troubleshoot this? I can't identify the mistake as it is telling me I need a ; after a while loop....

 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
sorry! I identified the error... I needed a semicolon after the P2OUT dec....

one thing that I don n ot understand though... it is telling me that where the else line is, a statement is expected... isn't it what I am already doing inside the parenthesis?
 

Thread Starter

em_cardc

Joined Apr 5, 2016
43
I hate those missing semicolons or mismatched braces. They cause many misleading errors.
I know.. :/ one last thing.. I did check the syntax and I am trying to produce the else statement with no errors.... unfortunately I already tried the if () { } else { } attempt and it keeps producing an error.
 

WBahn

Joined Mar 31, 2012
29,979
Or if you would format your code in any reasonable way brace mismatches become much easier to spot. If you use the Allman style of indenting, they become pretty trivial in most cases.

Also, always remember that the first error/warning reported may not be on the line it is reported. That is merely the spot where the compiler got so confused it had to finally say something. Always be willing to look upwards through code. Furthermore, while it is worth examining errors/warnings beyond the first one that is reported, don't invest a lot of time on them because they are frequently bogus artifacts of the earlier issues.
 

WBahn

Joined Mar 31, 2012
29,979
The Arduino IDE has an autoformat text option in the Tools sub-menu. It automatically indents your code properly.
Can you choose a style, such as the Allman style? Of the two IDEs I presently use most of the time, one let's me choose that style (from among about a dozen options) and the other does a pretty good job of automatically detecting the style I am using -- not globally, but in each case as I type. Very handy, particularly once I turn of all the autocomplete crap.
 

WBahn

Joined Mar 31, 2012
29,979
No, it does not allow selection of the style.
That's a shame, but not at all surprising. An editor specific to a particular platform is generally going to have fewer bells and whistles than a more generic platform. Just the natural way of things.
 

djsfantasi

Joined Apr 11, 2010
9,156
I agree with you. I have found the structured (and consistent) layout of the code, plus the feature of on demand highlighting of braces, parentheses and brackets, useful features.
 
Top