breathe icon indicating copy to clipboard operation
breathe copied to clipboard

C struct with enum render fault !

Open WuYingzheng opened this issue 4 years ago • 2 comments

I have a following c struct enum_struct with union members:

/**
 *  @brief a test group
 *  @defgroup test
 *  @{
 */

/** This is struct a */
struct struct_a {
    int a;
    short b;
};

/** This is struct b */
struct struct_b {
    long a;
    short b;
};

struct enum_struct {
    /** a test int val */
	int val;
    /** a test union */
	union {
		/** first struct */
		struct struct_a a;
		/** second struct */
		struct struct_b b;
	} auth;
};

/* @} */

it will generate the following result, in fact struct struct_a a & struct struct_b b belong to the union auth, not a member of struct enum_struct . The following result indicates that struct enum_struct have two members a & b, which is not expected.

image

So, can you help fix this issue? Thank you~

WuYingzheng avatar Apr 21 '20 14:04 WuYingzheng

This might be related to #447 and/or #369, I am not entirely sure. It might also be a problem in Sphinx's C or C++ domain, which is at https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/domains/c.py. and at the same path cpp.py.

At the very least I can conclude this happens in both Sphinx C and Sphinx C++ domain, just C domain renders enum_struct.[anonymous] auth and C++ renders enum_struct::[anonymous] auth. Besides that they both render in the same way.

So either it is a bug in Breathe, or it is a bug in Sphinx in both domains at the same time. I am not sure at this point, this will need some investigation but I probably won't have time to do this myself anytime soon.

Tested with Sphinx 3.0.2 and Breathe 4.16.0.

vermeeren avatar Apr 21 '20 17:04 vermeeren

I looks like a Doxygen XML bug to me. The enum_struct directly contains the shown members even though it shouldn't:

<compoundname>enum_struct</compoundname>
      <sectiondef kind="public-attrib">
      <memberdef kind="variable" id="structenum__struct_1a9fa68e2fa9c6819b65ddf3032dd43ee8" prot="public" static="no" mutable="no">
        <type>int</type>
        <definition>int enum_struct::val</definition>
        <argsstring></argsstring>
        <name>val</name>
        ...
      </memberdef>
      <memberdef kind="variable" id="structenum__struct_1aabc2a9f41764c672f0bcb920d675a087" prot="public" static="no" mutable="no">
        <type>struct <ref refid="structstruct__a" kindref="compound">struct_a</ref></type>
        <definition>struct struct_a enum_struct::a</definition>
        <argsstring></argsstring>
        <name>a</name>
        ...
      </memberdef>
      <memberdef kind="variable" id="structenum__struct_1a7d17477339a3a60b450c7b6caccc357c" prot="public" static="no" mutable="no">
        <type>struct <ref refid="structstruct__b" kindref="compound">struct_b</ref></type>
        <definition>struct struct_b enum_struct::b</definition>
        <argsstring></argsstring>
        <name>b</name>
        ...
      </memberdef>
      <memberdef kind="variable" id="structenum__struct_1a826957ab69c11dbc53c514fb79ca584d" prot="public" static="no" mutable="no">
        <type>union enum_struct::@0</type>
        <definition>union enum_struct::@0  enum_struct::auth</definition>
        <argsstring></argsstring>
        <name>auth</name>
        ...
      </memberdef>
      </sectiondef>
    ...
  </compounddef>

(Doxygen version 1.8.13)

jakobandersen avatar May 22 '20 11:05 jakobandersen