[xsd-users] XSD generates uncompilable code

Thomas Müller th.mueller at weisang.com
Wed Mar 15 10:56:30 EST 2006


Hi Boris,

> 
> > 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.

It seems that we still have to wait until we get a fully standard compliant
VC++...

> 
> 
> > 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.

Thanks for the hint, I did this already in the main project but not in the
sample.

> 
> 
> > 
> 1>c:\tools\xsd-2.0.0-i686-windows\examples\cxx\tree\library\library.hx
> > 1>x(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.
> 

Besides from the warnings mentioned above the code compiles now fine using
the updated elements.hxx. 
I tested basic access to the XML files and things are looking good so far.

Many thanks for your FAST support!

Thomas






More information about the xsd-users mailing list