C编程 - 多行注释

Amn*_*ngh 3 c syntax comments line

如何忽略多行注释符号的另一个多行注释?

假设我想将整个代码放在注释中,以便我可以在代码中测试其他内容

/* This is my first comment */
printf("\n This is my first print command");

/* This is my second comment */
printf("\n This is my second print command");
Run Code Online (Sandbox Code Playgroud)

如果我做

/* 

/* This is my first comment */
printf("\n This is my first print command");

/* This is my second comment */
printf("\n This is my second print command");

*/
Run Code Online (Sandbox Code Playgroud)

这是在创造错误.

Sou*_*osh 7

期望的是要嵌套的多行注释.

直接引用标准C11,第6.4.9章,

除了字符常量,字符串文字或注释之外,字符/* 引入注释.检查此类注释的内容仅用于标识多字节字符并查找*/终止它的字符.83)

和脚注,

83)因此,/* ... */评论不嵌套.

作为解决方法,您可以使用条件编译块作为

#if 0
.
.
.
.
#endif 
Run Code Online (Sandbox Code Playgroud)

将整个块注释掉.