[xsd-users] Linker error with double types when using wchar_t

Macumber, Daniel Daniel.Macumber at nrel.gov
Tue May 26 11:04:49 EDT 2009


I am having trouble with double types when using xsd cxx-tree with --char-type wchar_t in xsd 3.2.  Specifically, the linker seems to be looking for and missing methods returning special characters related to nan, infinity, etc that have to do with doubles.  I have modified the hello.xsd and driver.cxx files as shown below to add an optional double element ("number") to the schema and support the wchar_t character type.  I have seen related issues on this list before but none specifically mentioning the problem with double types.

Thanks a lot,
Dan

#################### Command line args ####################

xsd.exe cxx-tree --generate-serialization --generate-ostream --char-type wchar_t hello.xsd

#################### Changes to hello.xsd ####################

<?xml version="1.0"?>
<!--

file      : examples/cxx/tree/hello/hello.xsd
author    : Boris Kolpackov <boris at codesynthesis.com>
copyright : not copyrighted - public domain

-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:complexType name="hello_t">
    <xsd:annotation>
      <xsd:documentation>
        The hello_t type consists of a greeting phrase and a
        collection of names to which this greeting applies.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="greeting" type="xsd:string">
        <xsd:annotation>
          <xsd:documentation>
            The greeting element contains the greeting phrase
            for this hello object.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="name" type="xsd:string" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>
            The name elements contains names to be greeted.
          </xsd:documentation>
        </xsd:annotation>
      </xsd:element>
      <xsd:element name="number" type="xsd:double" minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="hello" type="hello_t">
    <xsd:annotation>
      <xsd:documentation>
        The hello element is a root of the Hello XML vocabulary.
        Every conforming document should start with this element.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>
</xsd:schema>

#################### Changes to driver.cxx ####################

int main (int argc, char* argv[])
{
  if (argc != 2)
  {
    cerr << "usage: " << argv[0] << " hello.xml" << endl;
    return 1;
  }

  try
  {
      string greeting(argv[1]);
    auto_ptr<hello_t> h (hello (wstring(greeting.begin(), greeting.end())));

    for (hello_t::name_const_iterator i (h->name ().begin ());
         i != h->name ().end ();
         ++i)
    {
      wcout << h->greeting () << ", " << *i << "!" << endl;
    }
  }
  catch (const xml_schema::exception& e)
  {
    wcerr << e << endl;
    return 1;
  }
}





More information about the xsd-users mailing list