Super comment

Started by
11 comments, last by phresnel 14 years, 7 months ago
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?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Advertisement
#if 0...#endif
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...
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.
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
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!
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
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?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Yep, it's under Edit->Advanced.
Yes this has pissed me off over the years as well, nested comment blocks would be nice.
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.

This topic is closed to new replies.

Advertisement