Can I comment out code blocks that contain comments?
Tell me I have a code like this
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
and I would like to comment on the whole block like this
/*
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
*/
As you can see, even the SO code analyzer will not look at the last 2 lines of code comments. Can I comment out code blocks that contain comments?
edit: To clarify, I need this to be able to comment out large sections of code to check if a modified function can compile in a package that might not otherwise be compiled until all the changes are done.
source to share
As @Acroneos said, there is no way. This is common behavior in most programming languages. Comments as well as toheres are recognized by lexers. And lexers work with context-free grammars. that is, lex can usually only recognize expressed expressions.
You can still use the C / C ++ ( #if 0
/ #endif
) approach . See Conditional Compilation . But it doesn't look "so nice".
begin
something1;
$if false $then
something2;
$endif;
endl;
source to share
No, because everything between the first delimiter until the next last delimiter will be recognized as a comment (= not handled by the compiler). This is how multiline comments work: if the first delimiter (/ *) is recognized, the compiler will ignore everything until the very next delimiter (* /) is recognized. Now that you know this, you should understand why your second / * will never be recognized by the compiler as a comment delimiter.
However, you can mark comments with special characters or concatenations in the multi-line comment sector to output comments to different sections.
source to share