4

Is there a proper/recommended way to add a short Doxygen comment to a C struct member variable when you're trying to obey an 80-char width-limit?

E.g.

// MyStruct.h

#ifndef MY_H
#define MY_H

typedef struct MyStruct
{
  struct in
  {
    int i_;                             ///< A number
    MQTTAsync_connectionLost connLost_; ///< Callback invoked upon loss of
                                        ///< connection
    char c_;                            ///< A letter
  } in_;
} MyStruct;

#endif

The above doesn't seem the right way to document connLost_ while obeying an 80-char width limit: it ends up generating the description of connLost under a "Field Documentation" subsection instead of along-with its peer member variables.

#ifndef MY_H
#define MY_H

typedef struct MyStruct
{
  struct in
  {
    int i_;                             ///< A number
    MQTTAsync_connectionLost connLost_; ///< Callback invoked upon loss of \
                                             connection
    char c_;                            ///< A letter
  } in_;
} MyStruct;

#endif

That is wrong differently: although connLost_ is documented along with its peers, the word "connection" (everything after the backslash) is dropped from the documentation.

#ifndef MY_H
#define MY_H

typedef struct MyStruct
{
  struct in
  {
    int i_;                             ///< A number
    /** Callback invoked upon loss of connection */
    MQTTAsync_connectionLost connLost_;
    char c_;                            ///< A letter
  } in_;
} MyStruct;

#endif

That isn't what I want either: connLost_'s documentation goes back to being in the "Field Documentation" section instead of along with its peers.

Pictorially, what I'd like to achieve, in a "doxygen-native" manner: enter image description here

2
  • Have you considered putting a line break between MQTTAsync_connectionLost and connLost_? Commented May 14, 2019 at 2:51
  • @Draconis - I did, and I'm not opposed to that (but it's not my preferred solution), but I'd like to learn if there's a "doxygen-native" solution to this. Commented May 14, 2019 at 2:52

1 Answer 1

6

What you did in the second example is ok. You just have to include a \brief!

#ifndef MY_H
#define MY_H

typedef struct MyStruct
{
  struct in
  {
    int i_;                             ///< A number
    // NOTE THE BRIEF HERE
    /** \brief Callback invoked upon loss of connection */
    MQTTAsync_connectionLost connLost_;
    char c_;                            ///< A letter
  } in_;
} MyStruct;
#endif
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.