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 dsPIC30/33 and PIC24.

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 dsPIC30/33 and PIC24,

int /* type */ i /* identifier */;

parses as:

int i;

Note that the mikroC PRO for dsPIC30/33 and PIC24 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 dsPIC30/33 and PIC24 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.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code