Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 286
Etienne Dechamps Avatar asked Dec 23 '11 16:12

Etienne Dechamps


People also ask

How do you write a comment in a method in C#?

Compilers ignore the comment entries and do not execute them. Generally, programming languages contain two types of comments but in C#, there are 3 Types of comments : Single Line Comments : It is used to comment a single line. These comment can be written in a separate line or along with the codes in the same line.

What is C IntelliSense?

IntelliSense features in C++ IntelliSense is a name given to a set of features that make coding more convenient. Since different people have different ideas about what is convenient, virtually all of the IntelliSense features can be enabled or disabled in the Options dialog box, under Text Editor > C/C++ > Advanced.

How do you make good comments in C++?

Single-line comments (informally, C++ style), start with // and continue until the end of the line. If the last character in a comment line is a \ the comment will continue in the next line. Multi-line comments (informally, C style), start with /* and end with */ .

How do I enable IntelliSense in Visual Studio?

To access this options page, choose Tools > Options, and then choose Text Editor > C# > IntelliSense.


2 Answers

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.

like image 199
Marcus10110 Avatar answered Sep 26 '22 19:09

Marcus10110


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

like image 34
Maciej Szpakowski Avatar answered Sep 23 '22 19:09

Maciej Szpakowski