[xsd-users] Warning while using maxUnsignedInt with c++98 standard with xsd3.3

Florin Hillebrand florin.hillebrand at streamunlimited.com
Mon Mar 21 11:19:00 EDT 2011


Hi all,

first my environment:

- ubuntu 10.04 on x86 32bit
- xsd3.3
- g++-4.4 with -stdc=c++98 -Wall compiler options.

I have an xsd which generates me a element with an attribute of type
xsd:unsignedInt with a default value. The default value has to be the
maximal unsigned int value (4294967295).

----------
<xsd:element name="Element">
  <xsd:complexType>
      <xsd:attribute name="attr" use="optional" type="xsd:unsignedInt" default="4294967295" />
  </xsd:complexType>
</xsd:element>
----------

When xsd 3.2 generated the cxx-tree i got back a constant and a method:

----------
const Element::attr_type Element::attr_default_value_ (
        ::xsd::cxx::tree::traits< ::xml_schema::unsigned_int, char >::create (
          ::std::string ("4294967295"), 0, 0, 0));


const Element::attr_type& Element::attr_default_value () {
        return attr_default_value_;
      }
---------

This works well without any compiler warnings, but when I updated xsd to
3.3 it generates me:

---------
const Element::attr_type& Element::attr_default_value () {
        return 4294967295;
      }
---------

This generates a g++ warning (Warnings treaded as errors):

------------
error: this decimal constant is unsigned only in ISO C90
------------

c++98 standard says:

---cite---- ISO/IEC 14882:1998(E)  page 42 point 2 ------
If it is decimal and has no suffix, it has
the first of these types in which its value can be represented: int,
long int;
-----------

So this won't work, but:

---cite---- ISO/IEC 14882:1998(E)  page 42 point 2 ------
If it is suffixed by u or U, its type is the first of these types in
which its value can be represented: unsigned int, unsigned long int;
-----------

This would work but i can't append an u or U to the default value,
because regex wouldn't pass.

I would appreciate any suggestions.

With kind regards,

Florin

-- 
The information contained in this message may be confidential and
legally protected under applicable law. The message is intended solely
for the addressee(s). If you are not the intended recipient, you are
hereby notified that any use, forwarding, dissemination, or reproduction
of this message is strictly prohibited and may be unlawful. If you are
not the intended recipient, please contact the sender by return e-mail
and destroy all copies of the original message.



More information about the xsd-users mailing list