I am looking for the best way to comment out multiple lines (rather methods) in C++ which have comments within them. I did check out some posts on SO but couldn't get the full details on using something like if #0
.
I did check out this post Nested comments in Visual C++? but I am not on the Windows platform.
You are almost correct; essentially it is being suggested to "if-def" the section of code out. What you want to do is use the precompiler directive #if
to block the code for you. Ex below shows that I want to ignore everything between the if and endif.
#if 0
/* Giant comment
it doesn't matter what I put here */
// it will be ignored forever.
#endif
To answer your question in general though; there is not a way to have compound comments, i.e.
/*
/* */ <--- this closes the first /*
*/ <--- this dangles.