How to write C++ comments that show up in 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.

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(); }

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

  • ///
  • <summary></summary> tags
  • Building with /doc (by setting the "Generate XML documentation files" option in the project settings)

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


This now supported in VS 2012!

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++).

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.


I'm not sure which version of Visual Studio introduced that but in VS 2015 you can simply put comment above a function, method, class, struct, union, enum class, namespace or even individual variables (locals too) and it will be shown by Intellisense. If you want to document something from a different module, you have to write a comment in the header file. Examples: Function Class Variable


Try installing Visual Assist and using doxygen style:

/**
* COMMENT DESCRIBING A CLASS
**/
class Foo
{
   public:
      /**
      *   \brief A foo method.
      *
      *   More complete description of foo.
      *   
      *   \param i A foo parameter.
      *   \return An int
      *
      **/
      int fooMethod(int i);

   private:
      int i; /*!< COMENT OF A MEMBER */

};

I haven't used VS2010 is too many years to remember whether this worked there or not. But what I have done for years in many different version of VS is ...:

#pragma region foo(float)
/// <summary> .... </summary>
/// <param name="bar"> .... </param>
/// <returns> .... </returns>
int foo(float bar)
{
    // stuff
}
#pragma endregion

In other words, manually putting in exactly what Visual Studio will automagically put in for C# code for you.

Then give the Intellisense engine a minute or so to reparse the file. Doing a build will force it to reparse, of course.

As I recall, this works in the most recent VS2010 Express Community, but I don't recall whether it worked in VS2010 Ultimate.