X宏打破氧气笔迹 [英] X-macro breaks doxygen callgraph

查看:61
本文介绍了X宏打破氧气笔迹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个文件:

test.c

int table[] = {
    #define X(val)    val,
    #include "test.x"
    #undef X
};
void level2(void) {
    level3();
    level4();
}
void level3(void) {
    level4();
}

test2.c

void level1(void) {
    level2();
    level3();
    level4();
}
void level4(void) {
}

test.x

X(1)
X(2)
X(3)

我使用doxygen为这些函数创建调用图。这是我的预期:

I use doxygen to create callgraphs for these functions. Here's what I expected:


  • level1:

    • 引用level2(),level3( )和level4()。


    • 引用level3() ,以及level4()。

    • 由level1()引用。


    • 引用level4()。

    • 由level1()和level2()引用。


    • 由level1(),level2()和level3()引用。

    但这是我得到的:


    • 级别1:

      • 引用level2(),level3()和level4()。


      • 由level1()引用。


      • 由level1()引用。


      • 由level1()引用。

      似乎test.c上的X宏是元凶。我设法通过做
      2件事(两者都会做)使其工作:

      It seems X-macro on test.c is the culprit. I managed to make it work by doing 2 things (either will do):


      1. 重命名 test .x ,因此doxygen找不到它。它将显示警告,但
        调用图是正确的。

      2. test.x 的末尾添加尾随换行符。通常,文件会在 X(3)之后立即结束

      1. Renaming test.x so doxygen doesn't find it. It will show warning, but callgraph is correct.
      2. Adding trailing newline at the end of test.x. Normally file would end immediately after X(3).

      问题:

      如何在不编辑文件的情况下从doxygen中获得可靠的笔迹?
      是否需要更改设置还是这个简单的错误?

      How can I get reliable callgraph out of doxygen without editing the files? Is there a setting I need to change or is this plain bug?

      推荐答案

      我在xmacros。通常,Doxygen会将宏视为适当的声明,而不实际对其进行预处理。为了使宏正常工作(这包括x宏)。通常:

      I've had varying experience with xmacros. In general Doxygen will treat macros as proper declarations and not actually preprocess them. In order to get macros working (and this includes x-macros). In general:


      1. 设置 MACRO_EXPANSION = yes

      2. 设置为 EXPAND_ONLY_PREDEF =是(这会使Doxygen扩展 all 宏)或

      3. 添加宏的名称为 EXPAND_AS_DEFINED

      1. Set MACRO_EXPANSION=yes
      2. Either set EXPAND_ONLY_PREDEF=yes (which will make Doxygen expand all macros) or
      3. Add the name of your macro to EXPAND_AS_DEFINED.

      另外,请注意: http://www.doxygen.nl/manual/config.html#cfg_skip_function_macros

      为了让您了解xmacros和Doxygen的可能,我可以从中生成适当的文档: https://github.com/couchbase/libcouchbase/blob/master/include/libcouchbase/error.h# L95

      To give you an idea about what's possible with xmacros and Doxygen, I can generate proper documentation from this: https://github.com/couchbase/libcouchbase/blob/master/include/libcouchbase/error.h#L95

      这篇关于X宏打破氧气笔迹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆