X-macro breaks doxygen callgraph

I have 3 files:

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) 

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

  • level1:
    • Links level2 (), level3 () and level4 ().
  • level2:
    • References level3 () and level4 ().
    • Link to level1 ().
  • level3:
    • Links level4 ().
    • Link to level1 () and level2 ().
  • level4:
    • Link to level1 (), level2 () and level3 ().

But here is what I got:

  • level1:
    • Links level2 (), level3 () and level4 ().
  • level2:
    • Link to level1 ().
  • level3:
    • Link to level1 ().
  • level4:
    • Link to level1 ().

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

  • Renaming test.x , so doxygen does not find it. It will show a warning, but the callgraph is correct.
  • Add a test.x newline at the end of test.x Usually the file ends immediately after X(3) .

Question:

How can I get a reliable callgraph from doxygen without editing files? Is there a parameter that I need to change, or is this a simple mistake?

0
source share
1 answer

I had experience with xmacros. In general, Doxygen will process macros as valid declarations and not actually process them. In order to work with macros (and this includes x-macros). Generally:

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

Also, pay attention to the following: http://www.stack.nl/~dimitri/doxygen/manual/config.html#cfg_skip_function_macros

To give you an idea of ​​the possibilities with xmacros and Doxygen, I can create the relevant documentation from this: https://github.com/couchbase/libcouchbase/blob/master/include/libcouchbase/error.h#L95

+1
source

Source: https://habr.com/ru/post/1264603/


All Articles