【问题标题】:Why macro defined within a C function is not documented by Doxygen?为什么 Doxygen 没有记录在 C 函数中定义的宏?
【发布时间】:2015-12-22 15:55:49
【问题描述】:

我在名为 foo.c 的文件中有以下代码。

/** @file */
#include <stdio.h>

/** Prints hello */
#define hello() printf("hello, ")

int main()
{
    /** Prints world */
    #define world() printf("world\n")
    hello();
    world();
}

我在同一目录中有一个名为 Doxyfile 的文件。

PROJECT_NAME = Foo
JAVADOC_AUTOBRIEF = YES

当我运行doxyfile 命令时,我得到一个类似这样的文档。

为什么没有为world() 宏生成文档?如何确保也为 world() 宏生成文档而不将其带出函数 main()

【问题讨论】:

  • 既然宏有全局作用域,为什么不能在main()的定义之前定义world()
  • 您是否尝试将#define 和评论移至第 1 列?
  • 可能 Doxygen 使用过时的规则进行宏对齐(或具有类似过时或错误定义规则的解析器)。 Pre-ANSI C,macros were not allowed to have whitespace between the beginning of the line and the #.
  • #define 及其评论移至第 1 列没有帮助。
  • 当一个工具。像编译器或链接器或某些文档工具(如 doxygen)表明代码有问题,而不是与工具对抗,而是修复问题。在这种情况下,将 #define 语句移到 main() 函数的签名之前

标签: c doxygen


【解决方案1】:

函数体中的宏/变量/等是outside the scope of Doxygen,因此目前没有为它们生成文档。

【讨论】:

    猜你喜欢
    • 2011-05-31
    • 1970-01-01
    • 2016-05-07
    • 2016-12-04
    • 1970-01-01
    • 2011-11-05
    • 2011-04-09
    • 2017-07-07
    • 1970-01-01
    相关资源
    最近更新 更多