Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Suggestion: #if 0 comment coloring

(1/2) > >>

Edis Krad:
Hiyas. First of all, thanks to the CodeBlocks developers for such a wonderful IDE!! Keep up the good work, guys :D

Anyways, when I'm debugging, I tend to comment out huge chunks of code by using #if 0 .... #endif for C/C++ languages. I find this much more practical than /* ... */ since the latter fails when there's already something commented with asterisks.

For example, while this works:


--- Code: ---#if 0 //commented out
/*This is a a huge chunk of code*/
void somefunction()
{
...
}
#endif //commented out

--- End code ---

this fails


--- Code: ---/* commented out
/*This is a a huge chunk of code*/
void somefunction()   //these
{                     //lines
...                   //remain
}                     //uncommented
commented out */

--- End code ---


What I'm suggesting is, if you deem it practical ( and it's not too much work :P ), instruct the editor to color everything between #if 0 and #endif as a comment as well for C / C++ languages.

Thanks!

wxLearner:
Hello,
did you try Code::Blocks' comment/uncomment feature? It's in the edit menu. Just select a block of code and press ctrl+shift+c to comment it or ctrl+shift+x to uncomment it.

alextj:
This topic is very old, but I still face a similar issue to the original poster.

Commenting out large blocks of code with #if 0/#endif is better than using ctrl+shift+c, because you can fold the #if/#endif code out of your way using Code::Blocks code folding.

Using ctrl+shift+c will add // in front of each line, which will leave this huge chunk of currently unneeded code in your way, not being able to fold it.

So it would be really nice to give #if 0 code a "commented" color. In any case it gives a better visual clue to the fact that the code is not being compiled - just like normal comments.

oBFusCATed:
Have you tried latest nightlies? There is similar feature.
The #ifdef 0 blocks are grayed out or something like that. I'm not sure if it is enabled by default.

BTW: There is the /* */ style of comments and they are foldable. I've can comment code with this style of comments with ctrl+shift+v (I don't remember if it is a custom patch which adds this functionality).

alextj:
Thanks for your quick answer oBFusCATed.


--- Quote from: oBFusCATed on April 29, 2011, 02:23:49 pm ---Have you tried latest nightlies? There is similar feature.
The #ifdef 0 blocks are grayed out or something like that. I'm not sure if it is enabled by default.

--- End quote ---
I didn't try latest nightlies. If the feature is in latest nightlies, does it mean that it might be in the official Code::Blocks release in a near future?


--- Quote from: oBFusCATed on April 29, 2011, 02:23:49 pm ---BTW: There is the /* */ style of comments and they are foldable. I've can comment code with this style of comments with ctrl+shift+v (I don't remember if it is a custom patch which adds this functionality).

--- End quote ---
I guess it is a custom patch, since it doesn't work in the latest version (10.05).
Of course using /* */ for commenting out large parts of code will fail, as the original poster have mentioned. But anyway, this would be a handy feature for quick inline commenting.

Navigation

[0] Message Index

[#] Next page

Go to full version