[xsd-users] XSD generates uncompilable code

Boris Kolpackov boris at codesynthesis.com
Wed Mar 15 09:02:11 EST 2006


Thomas,

Thomas Müller <th.mueller at weisang.com> writes:

> I have some trouble with uncompilable code in MSVC++ 8.0.

This appears to be a bug in VC++ (both 7.1 and 8.0). Here is a small
test case:

namespace n
{
  class type {};
}

class foo: public ::n::type
{
public:
  struct type
  {
    typedef int type_;
  };

  type::type_
  type ();
};

VC++ injects the n::type name into foo's scope but then does not notice
that it has been hidden by the foo::type declaration. Later, when we
refer to type::type_, it tries to fine type_ in n::type rather than
in foo::type.

I have a workaround for you here:

http://codesynthesis.com/~boris/tmp/elements.hxx

Replace you xsd-2.0.0-i686-windows/libxsd/xsd/cxx/tree/elements.hxx with the
file above.


> xsd cxx-tree --generate-inline --generate-ostream --morph-anonymous
> --generate-serialization xlink.xsd
>
> xsd cxx-tree --generate-inline --generate-ostream --generate-serialization
> library.xsd

Note that you need to add the --morph-anonymous option to the second
invocation as well if you want library.hxx to use types generated in
xlink.hxx.


> 1>c:\tools\xsd-2.0.0-i686-windows\examples\cxx\tree\library\library.hxx(329)
> : warning C4099: 'library::test_type::type' : type name first seen using
> 'class' now seen using 'struct'

I also fixed this warning. The fix will appear in the next release.


Thanks for reporting this and let me know if you still have problems with
the workaround above.

-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060315/dad575e7/attachment.pgp


More information about the xsd-users mailing list