开发者

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

开发者 https://www.devze.com 2023-04-03 17:00 出处:网络
My teams C-code guidelines write that it\'d be better to place a \'&l开发者_运维问答t;\' in a comment like shown below:

My teams C-code guidelines write that it'd be better to place a '&l开发者_运维问答t;' 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 '<' ?


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.


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.


It is a doxygen syntax for commenting members after declaration/definition.


I assume your team uses some automated documentation tool which looks for /**<; e.g. Doxygen.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号