Handling two different functions with the same name in Doxygen

前端 未结 4 1837
梦谈多话
梦谈多话 2021-01-17 18:02

I have a C project which contains two functions with the same name, but each is within a different group/module (@defgroup).

These functions each compil

相关标签:
4条回答
  • 2021-01-17 18:35

    can this work for you?

    The example is stripped down to the two files a.c and b.c, with only one function (the clashing) function.

    file a.c

    /**
     * \defgroup agroup Group A
     */
    
    /** 
     * the function in a, 
     * see also \link b.c myfunc() \endlink the other one 
     * \ingroup agroup
     */
    void myfunc() {
        ;
    }
    

    file b.c

    /**
     * \defgroup bgroup Group B
     */
    
    /** 
     * the function in b, 
     * see also \link a.c myfunc() \endlink the other one 
     * \ingroup bgroup
     */
    void myfunc() {
        ;
    }
    

    as you see, myfunc() has a name clash. I placed a link to the other function in the documentation.

    I perpended the function name by the filename.

    I compiled it with doxygen and the links worked (they linked from each documentation of a function to the other function).

    0 讨论(0)
  • 2021-01-17 18:37

    A solution that works for me in doxygen 1.8.13 is to provide an explicit link with the HTML <a></a> tag. For example, I have a function QF_run(), which is defined in three different files qv.c, qk.c and qxk.c. Here are three links to these three definitions:

    <a href="qv_8c.html#a779a1bc9482e2d489dc87751cd100fdb"><b>QF_run()</b></a>
    <a href="qk_8c.html#a779a1bc9482e2d489dc87751cd100fdb"><b>QF_run()</b></a>
    <a href="qxk_8c.html#a779a1bc9482e2d489dc87751cd100fdb"><b>QF_run()</b></a>
    

    These links are rendered in the HTML output the same way as the automatically generated links. The links are also stable as long as you don't change the name of the function.

    To obtain the hash-value for your function, simply open its documentation in a browser and copy the link after the # sign.

    0 讨论(0)
  • 2021-01-17 18:37

    No answer but same problem with C++ enums.

    We're generally lazy and copy the main.cpp from one of our CLI tool to the next... So they all contain:

    enum class Command {
        USAGE,
        SOME_COMMAND,
    }
    

    Most of these tools are diagnostics, PoC, live test tools for libs, etc...

    We build a single doc from all of our sources so the multiple declarations of this enum, even though they lie in different directories, will be found in the doc only once in the first file parsed and will contain ALL of the values declared in all the files... using clang parsing does not change anything there...

    That is quite misleading. The call graphs are wrong too of course...

    0 讨论(0)
  • 2021-01-17 18:38

    As far as I can see: doxygen's autolinking does not support having multiple functions with the same name.

    If there are multiple functions/methods with the same name, doxygen will simply link the first one it finds, as described in the question. The call graphs will also be incorrect. This seems to apply to all languages, not just to C.

    This has been reported as a bug multiple times:

    • #3676 bad links in source code browser for multiple functions of same name
    • #5448 Different Static Functions With Same Name Confusion
    • #979 Mismatched documentation for functions having same name
    • #3724 \relates confused on multiple static functions with the same name

    The section "Known problems" in doxygen's docs also describes a similar problem:

    It is not possible to insert a non-member function f in a class A using the \relates or \relatesalso command, if class A already has a member with name f and the same argument list.


    There is some hope; someone proposed a patch to better handle functions with the same name: #4365 getDefs fails to resolve local function names if same global name exist.

    This patch implements the following two strategies for resolving duplicated names. First, is the name is defined in current file, use the local name. Secondly try to match the names using the prototype definition.

    This would partly solve the problem. Unfortunately, the ticket has seen no activity since 2012...

    0 讨论(0)
提交回复
热议问题