47

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 '<' ?

Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
kingkai
  • 3,669
  • 3
  • 19
  • 13

4 Answers4

78

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.

albert
  • 8,285
  • 3
  • 19
  • 32
Michael Foukarakis
  • 39,737
  • 6
  • 87
  • 123
50

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.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
17

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

albert
  • 8,285
  • 3
  • 19
  • 32
Juraj Blaho
  • 13,301
  • 7
  • 50
  • 96
11

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

albert
  • 8,285
  • 3
  • 19
  • 32
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636