This style is most commonly used in the Java programming language, which shares much
of the same syntax as C.
I prefer the first form, which seems to be the form most
commonly used in the Arduino world.
Whitespace
The compiler ignores
spaces tabs and new lines, apart from using them as a way of
separating the “tokens” or words in your sketch. Thus the following example will compile
without a problem:
This will work, but good luck trying to read it.
Where assignments are made, some people will write the following:
But others will write the following:
Which of these two styles
you use really does not matter, but it is a good idea to be
consistent. I use the first form.
Comments
Comments are text that is kept in your sketch along
with all the real program code, but
which actually performs no programming function whatsoever. The sole purpose of
comments is to be a reminder to you or others as to why the code is written as it is. A
comment line may also be used to present a title.
The compiler will completely ignore any text that is marked as being a comment. We
have included comments as titles at the top of many of the sketches in the book so far.
There are two forms of syntax for comments:
• The single line comment that starts with
Dostları ilə paylaş: