Multi-Line Comments Nested in Single Line Comments
Author |
Message |
David Kit Friedma #1 / 5
|
 Multi-Line Comments Nested in Single Line Comments
What does the ANSI standard say about lines like the following: // this is a comment /* inside of a comment */ I'm working on a tool which has trouble parsing these kinds of lines although they are pretty common in a lot of the windows header files. David Friedman
|
Tue, 06 Jan 2004 02:39:36 GMT |
|
 |
Larry__Weis #2 / 5
|
 Multi-Line Comments Nested in Single Line Comments
Quote:
> What does the ANSI standard say about lines like the following: > // this is a comment /* inside of a comment */
6.4.9 Comments ... 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. Considering // this is a comment /* inside of a comment */ those // at the beginning make it all just a comment. - Larry Weiss
|
Tue, 06 Jan 2004 04:57:48 GMT |
|
 |
Deni #3 / 5
|
 Multi-Line Comments Nested in Single Line Comments
Larry, <snip> Quote: > 6.4.9 Comments > ... > 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.
while i could be wrong, i believe this to be a c9x interpretation of the comments. i think previous version of the standard did not allow for such comments, while they have been supported by some major compilers as extensions. of course, there is nothing in the original post that says *which* standard. the only reason i am making this comment is because c99 is not widely supported by compilers yet (i suppose gcc 3.0 starts down that road, but its flaky. i have no real data to back this statement up though) anyway, just my 2 cents hth, denis
|
Tue, 06 Jan 2004 13:39:06 GMT |
|
 |
Arthur H. Gol #4 / 5
|
 Multi-Line Comments Nested in Single Line Comments
Quote:
> Larry, > <snip> > > 6.4.9 Comments > > ... > > 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. > while i could be wrong, i believe this to be a c9x interpretation > of the comments. i think previous version of the standard did > not allow for such comments, while they have been supported by > some major compilers as extensions. > of course, there is nothing in the original post that says *which* > standard. the only reason i am making this comment is because > c99 is not widely supported by compilers yet (i suppose gcc 3.0 > starts down that road, but its flaky. i have no real data > to back this statement up though)
Yes, the quote is from the C99 standard. HTH, --ag -- Artie Gold, Austin, TX (finger the cs.utexas.edu account for more info)
-- "Those who can, do. Those who can't, teach. Those who can't teach, teach gym." -- W. Allen
|
Tue, 06 Jan 2004 14:18:06 GMT |
|
 |
Richard B #5 / 5
|
 Multi-Line Comments Nested in Single Line Comments
Quote:
> > 6.4.9 Comments > > ... > > 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. > while i could be wrong, i believe this to be a c9x interpretation > of the comments. i think previous version of the standard did > not allow for such comments, while they have been supported by > some major compilers as extensions.
True, it didn't. In that case, // This is... would be a syntax error. In the only C Standard that does allow // comments, the above quote holds. In non-standard extensions that allow // comments, well, anything goes; consulte thy compyler dockumentes. Richard
|
Tue, 06 Jan 2004 15:39:35 GMT |
|
|
|