Jump to content
  • Advertisement
Sign in to follow this  
Grain

Neat commenting trick i just discovered.

This topic is 4310 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

If you have commented out segments of code you want to toggle on and off you can do this. Start of with the regular "/*" but end your the section with "//*/" Now if you want to toggle change "/* to "//*"
//*
Some code 
more code
even more code
//*/


/*
Some code 
more code
even more code
//*/



Looks like it doesnt work in the forums source tags.

Share this post


Link to post
Share on other sites
Advertisement
Neat

i do:

#define DEUBG_1 1
#define DEBUG_2 0

#if DEBUG_1

...
...

#elif DEBUG_2

...
...

#endif


most development editors have mass commenting in and out for selections, VSC++, emacs.

Share this post


Link to post
Share on other sites
Quote:
Original post by iminyourbrain
most development editors have mass commenting in and out for selections, VSC++, emacs.


Yeah I know that. Though this does have a certain convenience to it. With those you have to highlight the entire section of text first. With this each segment of comment is controlled with one key stoke an the that control is placed right at the start of the code segment. And you don't have to hunt for the close comment. Also When the code is toggled on it still marks that code as something you may want to turn off later if you forgotten about it.

Share this post


Link to post
Share on other sites
If you want to toggle between two pieces of code you can even use:

/*
code A
/*/
code B //active
//*/

//*
code A //active
/*/
code B
//*/

[COOL]

Share this post


Link to post
Share on other sites
Quote:
Original post by samv
If you want to toggle between two pieces of code you can even use:

/*
code A
/*/
code B //active
//*/

//*
code A //active
/*/
code B
//*/

[COOL]
Oh, very nice. I'm sure ill make use of this.

Share this post


Link to post
Share on other sites
Instead of using comment, I usually do sth like this:


#if 0 // toggle to switch
// disabled code
#else
// enabled code
#endif

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!