News for hackers. Stuff that matters.
Re:The //* /*/ //*/ comment toggle trick by HardyLeung on Monday April 29, 2013 @11:15AM (#5626672)
As a long-time C++ developer I wish people don't use any commenting tricks such as this, and I wish people don't use /* * / to comment their code, even if you develop in C. Instead, use // in modern C/C++.

The reason is that we often need to comment OUT code during development. In C++, the 4 choices are: (1) #ifdef, (2) bool dothis = false; if (dothis) { ... }, (3) /* * /, (4) // ...

Among them, I would say the best and least-confusing way to comment out a block of code is /* * /. #ifdef's are very confusing especially if you have multiple of them; // needs to be applied to every line so only works in small scale; if (dothis) doesn't work across multiple functions, and at a glance it is harder to discern whether this is a "comment-out", or a legit condition.

However, by using /* * / in your comments, you eliminate the possibility of commenting out blocks of code that contains /* * / comments. The problem, of course, is due to how the opening and closing symbols are matched.

Re:The //* /*/ //*/ comment toggle trick by alexanderbrevig on Monday April 29, 2013 @11:18AM (#5626692)
"I'd appreciate if you'd have this discussion on Coderwall. That way I could 'defend' the post where it's due. However though, please read https://news.ycombinator.com/item?id=5626456 and summary is: It is a trick, not a silver bullet. It prevents code from being compiled to the binary, in a portable - yet hacky - way."
Re:The //* /*/ //*/ comment toggle trick by mzs on Monday April 29, 2013 @03:50PM (#5628261)
I've adopted:

#if 0 /* reason /

lines of messy stuff ...

#endif / reason */

That short comment makes it easy for me to find the ends.

Re:The //* /*/ //*/ comment toggle trick by mzs on Monday April 29, 2013 @03:52PM (#5628278)
Ha, I thought I put in the asterix-esses. You know what I mean, but I bet cpp actually ignores e everything after #if 0 and #endif, don't do that please ;)
Re:The //* /*/ //*/ comment toggle trick by wting on Monday April 29, 2013 @03:35PM (#5628167)
Some C projects still use -ansi and thus C++ comments (//) will result in a compiler error.