6.4.9 Comments

1

Except within a character constant, a string literal, or a comment, the characters /* introduce a comment. The contents of such a comment are examined only to identify multibyte characters and to find the characters */ that terminate it.[1]

2

Except within a character constant, a string literal, or a comment, the characters // introduce a comment that includes all multibyte characters up to, but not including, the next new-line character. The contents of such a comment are examined only to identify multibyte characters and to find the terminating new-line character.

3

EXAMPLE

"a//b"                              //   four-character string literal
#include "//e"                      //   undefined behavior
// */                               //   comment, not syntax error
f = g/**//h;                        //   equivalent to f = g / h;
//\
i();                                // part of a two-line comment
/\
/ j();                              // part of a two-line comment
#define glue(x,y) x##y
glue(/,/) k();                      // syntax error, not comment
/*//*/ l();                         // equivalent to l();
m = n//**/o
   + p;                             // equivalent to m = n + p;

Footnotes