Jump to content
  • Advertisement
Sign in to follow this  
V-man

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites

zfunction()
{
/*thing
thing
thing
if(ypasdafsdf)
{ thing
/*thing
thing*//*
}
thing
thing
thing*/
}


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 this post


Link to post
Share on other sites
Quote:
Original post by Lode
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...


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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by cache_hit
Quote:
Original post by Lode
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...


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 this post


Link to post
Share on other sites
Quote:
Original post by Firestryke31
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.


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!