> How does your class handle code like this?
> /* string s = "/* hello */ // how are you?"; */ string s = "/* // */";
Hey, here's something weird.
If you type my (top-of-head) code above into Visual Studio, it produces
one long line that's somehow a single comment, and none of it gets
compiled as actual code.
/* string s = "/* hello */ // how are you?"; */ string s = "/* // */";
But if you put a line break where you'd expect the first multi-line
comment to end -- without changing anything else -- then the second
statement gets syntax-coloured and compiled as C# code.
/* string s = "/* hello */ // how are you?"; */
string s = "/* // */";
So I think I've accidentally found a bug. What do I win?
Eq.
P.S. My question to the original poster still stands, bug or none!
Paul E Collins - 04 Mar 2008 22:08 GMT
Blah, never mind :) I worked out what's going on with that line.
This can serve as a lesson to anyone who would combine // and /**/
comments.
Eq.
Ben Voigt [C++ MVP] - 05 Mar 2008 15:27 GMT
> Blah, never mind :) I worked out what's going on with that line.
>
> This can serve as a lesson to anyone who would combine // and /**/
> comments.
You absolutely should combine // and /**/ comments. If you need to comment
out a block of code, you need to block prefix with // because /* */ style
comments do not nest.
Ben Voigt [C++ MVP] - 05 Mar 2008 15:26 GMT
>> How does your class handle code like this?
>> /* string s = "/* hello */ // how are you?"; */ string s = "/* // */";
[quoted text clipped - 10 lines]
> comment to end -- without changing anything else -- then the second
> statement gets syntax-coloured and compiled as C# code.
This just goes to show that where you'd expect the first comment to end is
not, in fact, where it does end.
Here is the first comment:
/* string s = "/* hello */
The */ inside quotes is NOT skipped because it is NOT inside a quoted string
literal because a quote inside a comment is a comment, not the beginning of
a string literal.