Search code examples
c++doxygeninitialization-list

Doxygen issue with C++ array initialization


I'm using Doxygen to generate an API for my current project and happened upon some strange behavior. Basically, if I use an initialization list to set a member array in a class's constructor, Doxygen does not produce proper output.

Here's a simple test class:

#ifndef TEST_HPP
#define TEST_HPP

class TestClass {
public:
    /** Constructor Version 1 */
    TestClass() : v{0,0,0} { }

    /** Constructor Version 2 */
    // TestClass() { 
    //     v[0] = 0;
    //     v[1] = 0;
    //     v[2] = 0;
    // }
protected:
    /** my little array */
    float[3] v;
};

#endif // TEST_HPP

If I run doxygen on the file with Version 1 of the constructor, I get a relatively empty HTML file for the class with no constructor documentation and no mention of my variable v. If I comment out Version 1 and use Version 2, Doxygen properly produces documentation for the class.

I know this type of array setting is new to C++11, but is it the initialization or the fact that it's done in an initialization list? If anyone knows what causes this behavior I'd appreciate it as we use these types of initializers all over the code and I'd like to avoid sweeping changes if necessary.


Solution

  • Doxygen v1.7.6.1 dates back to 10th December 2011. It's old.

    C++11 support was fundamentally added in v1.8.2; a bug in this support that seems to cover your case precisely (#688647 "Fixed problem parsing initializer list with C++11 style uniform types") was fixed in v1.8.3.

    The changelog is your friend in researching such things.

    The solution? Upgrade to acquire updates to doxygen's C++ parsing abilities.
    We're on v1.8.5 these days.