+ 1
Nested multi-line comments are not supported
12 Réponses
+ 6
When compiler sees /* (outer block start) it is taken as block comment start, and when it sees */ (inner block end) it is taken as block comments end. So your */ (outer block end) isn't considered the outer block comment end. The compiler fails to process the */ (outer block end) so whatever comes after it is not possible to be processed.
+ 3
this seen to be sololearn compiler, let me try another online compiler
+ 3
✳AsterisK✳ others don't work too:-)
+ 3
yeah i just noticed that too UraL
+ 3
the compiler read this line by line and after /* it meets / which will give an error
+ 3
Nested multiline comments are neither part of any standard nor useful so why should any compiler support them? Especially since supporting this might break older codes.
+ 3
Aaron Eberhardt For example, I commented out the program code. Then I want to comment out another part of the code, which includes the already commented code
+ 3
Ipang It would be possible to check the pairing / * - * / to implement. After all, nested blocks {} work
+ 3
UraL I see your problem. But it's not that hard to simply replace your comment. Also it's not a good practice to comment things out like that.
P.S. you can use if(false) { ... } as comment too if you really need it.
+ 2
UraL
That's just how the compiler was "taught", to ignore whatever between /* and */. If somehow there's a */ in between, it will take it as comment block end anyways.
I'm still not sure how this way of commenting is comparable to nested {}, or even a use case : )
+ 2
You can nest // inside /* */
+ 2
Sonic i know this