function pointer handling in Doxygen in C

↘锁芯ラ 提交于 2019-12-22 17:58:45

问题


In my code, a vtable containts several function pointer. Doxygen is unable to follow them.

I'd like to force it to recognize the possible paths, to produce a complete Call Graph, since now this part is missing.

example:

typedef Bool(*SPECIAL_FUNC)(KEY key);

typedef struct{
  int a;
  int b;
  SPECIAL_FUNC;
}OBJ;

Bool add(KEY key); //code...
Bool sub(KEY key); //code...

回答1:


While this will likely not affect the call graph in doxygen, you can document the functions as related to the structure, and provide links to them in the documentation for SPECIAL_FUNC. Something like:

typedef Bool(*SPECIAL_FUNC)(KEY key);

/**
 * struct description
 */
typedef struct{
  int a;
  int b;

  /**
   * Function pointer to one of the following:
   * - add()
   * - sub()
   */
  SPECIAL_FUNC;
}OBJ;

/**
 * @relates OBJ
 * add function.
 */
Bool add(KEY key); //code...

/**
 * @relates OBJ
 * sub function.
 */
Bool sub(KEY key); //code...

With this, OBJ will be documented as a class, add and sub will appear as related members of OBJ, and the documentation for SPECIAL_FUNC will contain links to add and sub.




回答2:


I don't think you can do this but one way of faking this could be to have special define just for this and only set it on for Doxygen (with PREDEFINED).

E.g.

#ifdef MY_DOXYGEN_FAKE
  KEY key;
  add(key);
  sub(key);
#endif

In functions where you use that function pointer. Of course it's more work since you have to make sure to only add calls to functions that you really use from that function. But then again you should know how that function pointer is used in any case.



来源:https://stackoverflow.com/questions/8574946/function-pointer-handling-in-doxygen-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!