jessevdk / cldoc

clang based documentation generator for C and C++
GNU General Public License v2.0
552 stars 58 forks source link

member fields for anonymous structures #100

Closed GlenCFL closed 9 years ago

GlenCFL commented 9 years ago

Anonymous structures, within something like a named union, seem to be stripped of the member fields that would otherwise be present in a named structure.

Generating XML from:

namespace test {

// union test
union v2 {
    // subscripting
    float values[2];
    // x, y
    struct {
        float x, y;
    };
    // a, b
    struct {
        float a, b;
    };
};

}

The generated contents of "test.xml" would be:

<?xml version='1.0' encoding='utf-8'?>
<namespace id="test" name="test" xmlns="http://jessevdk.github.com/cldoc/1.0">
  <union id="test::v2" name="v2">
    <brief>union test</brief>
    <struct name="(anonymous::1)" ref="test::v2::(anonymous::1)#test::v2::(anonymous::1)">
      <brief>x, y</brief>
    </struct>
    <field id="test::v2::values" name="values">
      <brief>subscripting</brief>
      <type size="2">
        <type builtin="yes" name="float" />
      </type>
    </field>
  </union>
</namespace>

Two issues with this:

These two issues compounded makes it impossible to document the existence of these fields using the generated XML. Fixing the first allows documentation of the fields using comments/brief, though that's a bit hacky.

jessevdk commented 9 years ago

Should be fixed. Please feel free to reopen if the problem still persists.