Syntax
A block comment begins with the forward-slash asterisk sequence/* and terminates with the first subsequent asterisk forward-slash sequence */.
Lexical Rules and Compiler Behavior
- Token Replacement: During translation phase 3 of the C compilation process, the preprocessor replaces the entire block comment (including its delimiters) with a single space character. Consequently, block comments cannot be used to concatenate adjacent tokens.
- String Literals and Character Constants: The
/*and*/character sequences lose their special meaning when enclosed within string literals (" ") or character constants (' '). The compiler treats them as standard character data rather than comment delimiters.
- Line Splicing: If a line splice (a backslash
\immediately followed by a newline) occurs within a block comment, the compiler processes the splice during translation phase 2, prior to parsing the comment delimiters.
Nesting Constraints
Standard C strictly prohibits the nesting of block comments. The lexical analyzer terminates the comment at the very first*/ sequence it encounters, regardless of how many /* sequences preceded it. Attempting to nest block comments exposes the remaining text to the compiler, typically resulting in a syntax error when it attempts to parse the trailing, unmatched */.
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More





