Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does a C comment like /* */ need '<'?

Tags:

c++

c

doxygen

My teams C-code guidelines write that it'd be better to place a '<' in a comment like shown below:

#define MAX_PACK_ITEM_NUM 50  /**<  max number of item */ 

I wonder, what is the real use of this '<' ?

like image 720
kingkai Avatar asked Sep 07 '11 06:09

kingkai


People also ask

Why do we need comments in C?

Use of Comments in CIt makes it easier for other developers to understand and use your code. While debugging there might be situations where we don't want some part of the code.

What is the difference between comments and /* comments?

What is the difference between // comments and /* style comments? The double-slash comments (//) expire at the end of the line. Slash-star (/*) comments are in effect until a closing comment mark (*/).

Why do you need comments in programming?

Comments are text notes added to the program to provide explanatory information about the source code. They are used in a programming language to document the program and remind programmers of what tricky things they just did with the code and also helps the later generation for understanding and maintenance of code.


2 Answers

It's a way for doxygen to generate documentation for members of a file/struct/union/class/enum. By using that marker, you can put comments after each member, leading to less clutter. You can read more about it here.

like image 81
Michael Foukarakis Avatar answered Oct 05 '22 14:10

Michael Foukarakis


As others have replied, this is probably a comment that is meant for doxygen. When parsing comments, doxygen have some special rules:

  • An ordinary comment starting with /* is ignored by doxygen.
  • A comment starting with /** is treated as documentation of the next item after the comment in the source code.
  • A comment starting with /**< is treated as documentation of the item immediately before the comment in the source code.

Documentation is mostly placed above the documented item, e.g. a function. But in some cases such as a #define it makes sense to put the documentation at the end of the line instead and in that case the /**< marker is needed.

like image 30
Anders Abel Avatar answered Oct 05 '22 14:10

Anders Abel