[xsd-users] Error: incomplete type when compiling cxx generated with --file-per-type

Yongchang Huang xjtu.yohuang at gmail.com
Fri Jul 21 22:18:47 EDT 2023


Hi xsd developers,

I need some help on cxx-tree cxx compilation error.

*Problem*

I used xsd-4.0.0 to generate cxx-tree files with --file-per-type option,
and then tried to compile the .cxx files. g++ reported incomplete type
error as shown below.


*Error message*


*/home/utils/gcc-9.3.0/bin/g++ -std=c++11 -c clockDriver.cxx -I
../../../xsd-4.0.0+dep/xsd/libxsd -I /home/utils/xerces-c-3.1.1/include*
*In file included from /home/utils/gcc-9.3.0/include/c++/9.3.0/memory:80,*
*                 from
../../../xsd-4.0.0+dep/xsd/libxsd/xsd/cxx/xml/char-utf8.txx:8,*
*                 from
../../../xsd-4.0.0+dep/xsd/libxsd/xsd/cxx/xml/char-utf8.hxx:44,*
*                 from builtin_types/index.hxx:62,*
*                 from clockDriver.hxx:62,*
*                 from clockDriver.cxx:41:*
*/home/utils/gcc-9.3.0/include/c++/9.3.0/bits/unique_ptr.h: In
instantiation of 'void std::default_delete<_Tp>::operator()(_Tp*) const
[with _Tp = ipxact::clockDriverType_clockPeriod]':*
*/home/utils/gcc-9.3.0/include/c++/9.3.0/bits/unique_ptr.h:292:17:
required from 'std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp =
ipxact::clockDriverType_clockPeriod; _Dp =
std::default_delete<ipxact::clockDriverType_clockPeriod>]'*
*clockDriver.cxx:108:21:   required from here*
*/home/utils/gcc-9.3.0/include/c++/9.3.0/bits/unique_ptr.h:79:16: error:
invalid application of 'sizeof' to incomplete type
'ipxact::clockDriverType_clockPeriod'*

*Xsd Snippet for xs:element clockDriverType*

<xs:schema xmlns:ipxact="http://www.accellera.org/XMLSchema/IPXACT/1685-2014"
xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="
http://www.accellera.org/XMLSchema/IPXACT/1685-2014"
elementFormDefault="qualified">

  <xs:include schemaLocation="simpleTypes.xsd"/>
  <xs:include schemaLocation="autoConfigure.xsd"/>
  <xs:include schemaLocation="commonStructures.xsd"/>
  <xs:element name="clockDriver">
    <xs:annotation>
      <xs:documentation>Describes a driven clock port. </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="ipxact:clockDriverType">
          <xs:attribute name="clockName" type="xs:string">
            <xs:annotation>
              <xs:documentation>Indicates the name of the cllock. If not
specified the name is assumed to be the name of the containing port.
</xs:documentation>
            </xs:annotation>
          </xs:attribute>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
 ....
  <xs:complexType name="clockDriverType">
    <xs:sequence>
      <xs:element name="clockPeriod">
        <xs:annotation>
          <xs:documentation>Clock period in units defined by the units
attribute. Default is nanoseconds.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="ipxact:realExpression">
              <xs:attribute name="units" type="ipxact:delayValueUnitType"
use="optional" default="ns"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
      ...

    </xs:sequence>
    <xs:attributeGroup ref="ipxact:id.att"/>
  </xs:complexType>
</xs:schema>


*Observations*

The clockDriverType contains a sequence of elements, one element is of type
clockPeriod. The generated clockDriverType.hxx contains only forward
declaration of clockDriverType_clockPeriod and no #include
"clockDriverType_clockPeriod.hxx".

Is this a bug or am I missing any xsd option to instruct xsd to add the
missing #include?


*How to reproduce*

The attached debug.tar file contains the .xsd files and a run.sh which
shows the xsd cxx-tree command and g++ command. You may need to update the
g++ or libxsd header path as needed.

Thanks,
yohuang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug.tar
Type: application/x-tar
Size: 358400 bytes
Desc: not available
Url : https://codesynthesis.com/pipermail/xsd-users/attachments/20230722/577d3df3/debug-0001.tar


More information about the xsd-users mailing list