C ++中的嵌套注释 [英] Nested Comments in C++

查看:171
本文介绍了C ++中的嵌套注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是一个常见的问题,可能类似于一些问题在这里,但我看着敌人的最好的方式注释多个行(而不是方法)在C + +其中有评论。我做了检查一些帖子在SO,但could not get the full details on using like like if#0。

This should be a common problem and possibly similar to some question here but i am looking foe 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 couldnt get the full details on using something like if #0 .

我检查了这个帖子在Visual C ++中嵌套的注释?但我不是在Windows平台上。

I did check out this post Nested comments in Visual C++? but I am not on the Windows platform.

推荐答案

你几乎是正确的;基本上是建议if-def的代码段。你想做的是使用预编译器指令 #if 来阻止你的代码。 Ex下面显示我想忽略if和endif之间的所有内容。

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.

这篇关于C ++中的嵌套注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆