如何编写出现在 Intellisense 中的 C++ 注释?

我正在使用 Visual Studio 2010 Ultimate 进行 C++ 编程.我想记录一些函数,并且我希望文档显示在 Intellisense 中.

I'm programming in C++ using Visual Studio 2010 Ultimate. I want to document some functions and I want the documentation to show up in Intellisense.

根据MSDN,我只需要将注释放在声明之前或之后在同一条线上.所以我尝试了这个:

According to MSDN, I just need to put the comment before the declaration or after it on the same line. So I tried this:

// This is a test.
void foo();
void bar() { foo(); }

将鼠标移到 foo() 上时,工具提示中不显示注释.我也试过:

When moving my mouse over foo(), the comment doesn't appear in the tooltip. I also tried:

  • ///
  • 标签
  • 使用 /doc(通过在项目设置中设置生成 XML 文档文件"选项)

到目前为止我没有运气.有没有人知道如何使这项工作?

I've had no luck so far. Does anyone know a way to make this work?

推荐答案

VS 2012 现在支持!

This now supported in VS 2012!

以前,注释中的 XML 标签只能由 C++/CLI 读取,而不是普通的旧 C++.VS 2012 现在至少将其中的一些带入常规 C++ - 它位于 Visual Studio 2012 的新增功能 和 MSDN 文档:XML 文档 (Visual C++).

Previously, XML tags in the comments were only read in by C++/CLI, not plain old C++. VS 2012 now brings at least some of this into regular C++ - it is in the What's New in Visual Studio 2012 and in the MSDN docs: XML Documentation (Visual C++).

我已经在 2012 Ultimate 中使用自己的应用程序对其进行了测试,我可以确认摘要、段落和 seealso 标签都被拉出格式用于工具提示.

I've tested it with my own application in 2012 ultimate, and I can confirm that the summary, para, and seealso tags are all pulled out an formatted for tooltips.

相关文章