c++ - Doxygen `@code` block 中的链接有时会丢失

标签 c++ doxygen

我注意到当默认构造函数不带参数时,Doxygen 可以链接来自实例的成员函数调用,但当构造函数带参数时无法链接它们。

  • 这是为什么?
  • 是否有在 @code/@endcode block 中手动添加链接的解决方法?

在下面的例子中:

  • t.foo() - foo() 已链接
  • u.foo() - foo() 未链接

.

/** @file doxy.cpp */

/** struct T */
struct T {
  /** foo */
  void foo() { }
};

/** struct U */
struct U {
  int a; /**< int a */

  /** U */
  U(int a_) : a(a_) { }

  /** foo */
  void foo() { }
};

/**
 * main
 *
 * @code
 * T t;
 * t.foo();  // foo is linked
 *
 * U u(42);
 * u.foo();  // foo is not linked
 * @endcode
 */
int main()
{
  return 0;
}

最佳答案

我认为这是 Doxygen 中已知问题的征兆。来自 http://www.doxygen.nl/manual/trouble.html

Redundant braces can confuse doxygen in some cases. For example:

void f (int); 

is properly parsed as a function declaration, but

const int (a);

is also seen as a function declaration with name int, because only the syntax is analyzed, not the semantics. If the redundant braces can be detected, as in

int *(a[20]); 

then doxygen will remove the braces and correctly parse the result.

所以在这种情况下,我相信:

U u(42);

被解释为函数而不是变量声明。

不幸的是,我不知道有任何选项可以在代码块中显式添加链接。我发现的唯一解决方法是重构代码,使声明看起来不像 Doxygen 的函数。例如,将您的变量初始化更改为:

U u = U(42);

允许 Doxygen 将 u 识别为变量而不是函数。

关于c++ - Doxygen `@code` block 中的链接有时会丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13048483/

相关文章:

c++ - 类和线性回归

c++ - OpenMP 是否复制私有(private)对象?

latex - Doxygen + MikTex hbox + vbox badness

c++ - Doxygen - 如何在不生成图表的情况下生成文本调用关系结果

linux - 在 linux 中为 qtcreator 添加 Doxygen 插件

c++ - Doxygen UML未显示属性,方法及其参数和返回值的类型

c++ - 如果共享内存的指针为空,则将其内容设置为空 c++

c++ - OpenCL的enqueueWriteBuffer导致__memcpy_sse2_unaligned segmentation fault

c++ - 使用 int 10h 从内联汇编打印 c char*

doxygen - Doxywizard 下一个按钮被禁用