Arduino Forum
>
Development
>
Suggestions for the Arduino Project
>
make the compiler friendlier by matching brackets
Print
Go Down
Pages:
[1]
Topic: make the compiler friendlier by matching brackets
(Read 1 time)
previous topic
-
next topic
adlmail
Newbie
Posts: 2
Karma: 0
[add]
make the compiler friendlier by matching brackets
Jan 23, 2018, 01:48 am
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
Shannon Member
Posts: 13,892
Karma: 1198
[add]
It gets hot so it must be working.
Re: make the compiler friendlier by matching brackets
#1
Jan 23, 2018, 02:05 am
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.
You will save everyone's time if you read and follow the forum guidelines.
https://forum.arduino.cc/index.php/topic,148850.0.html
https://forum.arduino.cc/index.php?topic=97455.0
https://forum.arduino.cc/index.php?topic=712199.0
aarg
Brattain Member
Posts: 16,983
Karma: 984
[add]
Re: make the compiler friendlier by matching brackets
#2
Jan 23, 2018, 02:20 am
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
Chrome App Beta
Faraday Member
Posts: 3,956
Karma: 488
[add]
Terry has designed broadcast stations, recording studios, broadcast equipment, intelligent machines and special computer languages for IBM, and has worked as a broadcast journalist covering elections, fires, riots and Woodstock. He has taught electronics
http://yourduino.com
Re: make the compiler friendlier by matching brackets
#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
Sr. Member
Posts: 365
Karma: 38
[add]
Re: make the compiler friendlier by matching brackets
#4
Jan 23, 2018, 02:48 am
In Visual Studio you can highlight one brace, click ctrl+] and the cursor will jump to the matching brace.
aarg
Brattain Member
Posts: 16,983
Karma: 984
[add]
Re: make the compiler friendlier by matching brackets
#5
Jan 23, 2018, 02:53 am
reply #1 is the solution
... 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
Guest
Re: make the compiler friendlier by matching brackets
#6
Jan 23, 2018, 01:21 pm
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.
Print
Go Up
Pages:
[1]
Loading...