0xbe5077ed
0xbe5077ed

Reputation: 4775

Doxygen -- How to link to a C++ file-scope global variable

I have some code that looks like this:

MyStruct.h

struct MyStruct
{
    // ...

    /**
      * \brief Initializes \link MYSTRUCT \endlink.
      */
    static void init();
};

/**
 * \var MYSTRUCT
 * \brief You must call MyStruct::init() before using this variable.
 */
extern MyStruct const * MYSTRUCT;

Question

I would like to have the Doxygen documentation on MyStruct::init link to the Doxygen documentation on MYSTRUCT. However, Doxygen can't resolve the link as I provide it. What do I need to do to make the link work?

NOTE: Doxygen v 1.8.4 on Windows 7

Upvotes: 2

Views: 4218

Answers (1)

doxygen
doxygen

Reputation: 14879

Here is the corrected example that should work. Note that I added a comment block with \file (and removed the redundant \var)

/** \file */

/** My struct documentation */
struct MyStruct
{
    // ...

    /**
     * \brief Initializes \link MYSTRUCT \endlink.
     */
    static void init();
};

/**
 * \brief You must call MyStruct::init() before using this variable.
 */
extern MyStruct const * MYSTRUCT;

If you don't want a page with global data, but want MYSTRUCT to appear as part of MyStruct's documentation you can use \relates like so:

/** My struct documentation */
struct MyStruct
{
  // ...

  /**
   * \brief Initializes \link MYSTRUCT \endlink.
   */
  static void init();
};

/**
 * \brief You must call MyStruct::init() before using this variable.
 * \relates MyStruct
 */
extern MyStruct const * MYSTRUCT;

and you can use #MYSTRUCT as a short-hand notation for \link MYSTRUCT \endlink

Upvotes: 5

Related Questions