1

I am trying to generate the callgraph for the main function in the following code, where I pass the MODE_A as predefine.

void FOO(int a);
void ZOO(int a);


#ifdef MODE_A
    #define function    FOO
#else
    #define function    ZOO
#endif

/**
 * @callgraph
 */
int main()
{
    function(69);
}

void FOO(int a){    cout << "FOO " << a;}

void ZOO(int a){    cout << "ZOO " << a;}

my settings in the Doxyfile are:

# Difference with default Doxyfile 1.8.20 (f246dd2f1c58eea39ea3f50c108019e4d4137bd5)
OPTIMIZE_OUTPUT_FOR_C  = YES
EXTRACT_ALL            = YES
CASE_SENSE_NAMES       = YES
GENERATE_TREEVIEW      = YES
MACRO_EXPANSION        = YES
PREDEFINED             = MODE_A
EXPAND_AS_DEFINED      = function
SKIP_FUNCTION_MACROS   = NO
HAVE_DOT               = YES

I even tried EXPAND_ONLY_PREDEF = YES. Is there any other setting I can try?

Debug Update I dumped the pre-processor output for the above code using doxygen -d Preprocessor. And did the same with macro function replaced with FOO. In both cases the output was exactly the same, which is as follows:

00014 /**
00015  * @callgraph
00016 */
00017 int main()
00018 {
00019     FOO(34);
00020 }
Yogesh
  • 33
  • 5
  • Do you have graphviz installed? – Shiv Jan 08 '21 at 19:03
  • Yes. I am able to generate graphs – Yogesh Jan 08 '21 at 19:06
  • https://www.doxygen.nl/manual/diagrams.html It says that it generates inheritance diagram for classes. – Shiv Jan 08 '21 at 19:11
  • @Shiv it also says at that place that it can create call / caller graphs. What is your intention of your comment in respect to the question of OP? – albert Jan 08 '21 at 19:15
  • I think we have here to do with the note as placed with the `\callgraph` command (see: ): "The completeness (and correctness) of the call graph depends on the doxygen code parser which is not perfect." The code parser does, to the best of my knowledge, not honor the settings used in `#define` / settings in the settings file (contrary to the scanner). – albert Jan 08 '21 at 19:24
  • The problem is that, to the best of my knowledge, the generation of the call graph uses the code generator which uses the bare input file and not the preprocessed file that is used for the code scanning and the main documentation. – albert Jan 09 '21 at 09:08
  • A problem also shows when (as a test) we would add the code `#ifdef MODE_A FOO(69); #else ZOO(69); #endif` instead of `function(69);`, in that case we would see in the call graph `FOO` **and** `ZOO`. (line breaks are not shown in the comment, but should be present of course). – albert Jan 09 '21 at 09:37
  • Thanks @albert! For now I got away with a python script to pre-process the source files before calling doxygen. Obviously not a solution, but it works. – Yogesh Jan 09 '21 at 18:20

0 Answers0