Comments
Comments are pieces of a text used to annotate a program and technically are another form of whitespace. Comments are for the programmer’s use only; they are stripped from the source text before parsing. There are two ways to delineate comments: the C method and the C++ method. Both are supported by mikroC PRO for ARM.
You should also follow the guidelines on the use of whitespace and delimiters in comments, discussed later in this topic to avoid other portability problems.
C comments
C comment is any sequence of characters placed after the symbol pair /*
. The comment terminates at the first occurance of the pair */
following the initial /*
. The entire sequence, including four comment-delimiter symbols, is replaced by one space after macro expansion.
In the mikroC PRO for ARM,
int /* type */ i /* identifier */;
parses as:
int i;
Note that the mikroC PRO for ARM does not support a nonportable token pasting strategy using /**/
.
For more information on token pasting, refer to the Preprocessor Operators.
C++ comments
The mikroC PRO for ARM allows single-line comments using two adjacent slashes (//
). The comment can start in any position and extends until the next new line.
The following code
int i; // this is a comment int j;
parses as:
int i; int j;
Nested comments
ANSI C doesn’t allow nested comments. The attempt to nest a comment like this
/* int /* declaration */ i; */
fails, because the scope of the first /*
ends at the first */
. This gives us
i; */
which would generate a syntax error.
What do you think about this topic ? Send us feedback!