Synopsis: | Comments in the form of opening (/*) and closing (*/) shall not be nested. |
Language: | C |
Severity Level: | 2 |
Category: | Lexical Elements |
Description: |
Justification C does not support nesting of comments. However, some compilers allow this as a language extension. If so, the following code will not give a syntax error but just compiles and treat the critical function call as comments. Example 1 /* some comment /* WRONG */ perform_critical_function(); /* some other comment */ Example 2 /* This code is bracketed out because ... /* RIGHT */ * code_to_be_excluded(); some other comment */ Note The main argument for nesting comments is that it would allow programmers to "comment out" code. However, comments shall be used for adding documentation to a program and preferably mechanisms that already exist for source code exclusion shall be used. |