# Super comment

This topic is 3199 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Sometimes in a block of C++ code, I have the /* */ and sometimes I want to comment all of the code so if I put another /* */, it becomes a headache. example
zfunction()
{
/*thing
thing
thing
if(ypasdafsdf)
{  thing
/*thing
thing*/
}
thing
thing
thing*/
}


Is there a solution to this?

##### Share on other sites
#if 0...#endif

##### Share on other sites
Or use // comments. In a good IDE or editor, you should be able to select the text you want to comment, and then press some key combination to //-ify it.

Personally, I never understood why they made /* */ not nestable. I can understand that in the 70's in the C programming language they might have done it to make the parser of the code a bit more efficient. But I don't understand that other curly brace language, like Java, followed this and still don't allow nesting /* */ comments...

##### Share on other sites
zfunction(){/*thingthingthingif(ypasdafsdf){  thing  /*thing   thing*//*}thingthingthing*/}

Closest I could get to a solution. I personally only use /**/ for header comments and use // to comment out code (it can be a PITA to do manually, but it's better than dealing with nested /**/ comments).

I hate GD.net's forum software, could someone tell my how to post code in code tags? I tried but the above is what happens.

##### Share on other sites
Quote:
 Original post by LodeOr use // comments. In a good IDE or editor, you should be able to select the text you want to comment, and then press some key combination to //-ify it.Personally, I never understood why they made /* */ not nestable. I can understand that in the 70's in the C programming language they might have done it to make the parser of the code a bit more efficient. But I don't understand that other curly brace language, like Java, followed this and still don't allow nesting /* */ comments...

It can't be represented with a regular expression that way, so the lexical analyzer becomes more complicated. C# allows nesting I believe, but in a language that operates on design-by-committee, it's really hard to get anything changed.

To the OP, if you're using Visual Studio, highlight everything and hit Ctrl+K C

##### Share on other sites
Some C compilers allow comment nesting, although that was non-standard behaviour. I doubt any major compiler still does it, at least by default.

But yeah, if you want to disable code that contains that kind of comments, use #ifdef 0 ... #endif. It also has the additional advantage that it can be nested!

##### Share on other sites
Quote:
Original post by cache_hit
Quote:
 Original post by LodeOr use // comments. In a good IDE or editor, you should be able to select the text you want to comment, and then press some key combination to //-ify it.Personally, I never understood why they made /* */ not nestable. I can understand that in the 70's in the C programming language they might have done it to make the parser of the code a bit more efficient. But I don't understand that other curly brace language, like Java, followed this and still don't allow nesting /* */ comments...

It can't be represented with a regular expression that way, so the lexical analyzer becomes more complicated. C# allows nesting I believe, but in a language that operates on design-by-committee, it's really hard to get anything changed.

To the OP, if you're using Visual Studio, highlight everything and hit Ctrl+K C

#if 0 is good but your Ctrl+K C is nice as well. It works in VC++ 2008 Express.
May I ask how did you learn about the Ctrl+K C?
Is it in the menu?

##### Share on other sites
Yep, it's under Edit->Advanced.

##### Share on other sites
Yes this has pissed me off over the years as well, nested comment blocks would be nice.

##### Share on other sites
Quote:
 Original post by Firestryke31I hate GD.net's forum software, could someone tell my how to post code in code tags? I tried but the above is what happens.

Take a look at this sticky thread which has some useful information on source tags.

• 32
• 12
• 10
• 9
• 9
• ### Forum Statistics

• Total Topics
631350
• Total Posts
2999478
×