Go Down

Topic: make the compiler friendlier by matching brackets (Read 953 times) previous topic - next topic

adlmail

The error messages that result from inadvertantly erasing a } bracket are so obscure they often do not lead to the problem.

How about adding a simple bracket counter so if there are a different number of left brackets than right brackets it tells you to look for that.  This would sure help us beginners.

groundFungus

Or adjust your writing style so that mis-matched brackets are easier to see.  Put every { and every } on its own line.
Code: [Select]
if(a ==1)
{
   If(b==1)
   {
      doThis;
   }
}


Couple that with auto format and misplaced brackets usually stand right out.

aarg

What version of the IDE do you have? The latest ones highlight bracket pairs and even display function names if they end one.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

terryking228

#3
Jan 23, 2018, 02:39 am Last Edit: Jan 23, 2018, 02:44 am by terryking228
Quote
The latest ones highlight bracket pairs
You need to click next to a bracket and then the matching one of the pair is highlighted.

Another help for bigger sketches is to use the free editor "Notepad++"  and set the language to C++. Then it highlights all the bracket pairs including embedded ones. See:

https://notepad-plus-plus.org/

That's what I use when I get really screwed up!
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

TKall

In Visual Studio you can highlight one brace, click ctrl+] and the cursor will jump to the matching brace.

aarg

  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

PaulS

Tools + Auto Format WILL tell you that you have the wrong number of right or left braces, or will line things up neatly, though not necessarily correctly, if you have the same number of each.
The art of getting good answers lies in asking good questions.

Go Up