From dave at simonsontech.net Thu Jul 22 16:42:28 2021 From: dave at simonsontech.net (Dave Simonson) Date: Fri Jul 23 05:33:31 2021 Subject: [xsd-users] OS-defined type names conflict with schema type names Message-ID: <027214b6-4881-7700-ac85-7cb6fece9d9a@simonsontech.net> Trying to map a large schema, the code generation seems to go well: $ xmllint --noout UCSM-IN.xsd $ cat xsd_opts.txt cxx-tree --output-dir /cygdrive/d/UCS_Xfer/schema_4.1.2/src --std c++11 #--generate-inline --generate-dep --show-sloc --generate-ostream --generate-doxygen --generate-polymorphic --generate-wildcard --polymorphic-type anyType --custom-type timezone=timezone_xs --custom-type clock=clock_xs --custom-type select=select_xs #--parts 40 $ xsdcxx --options-file xsd_opts.txt UCSM-IN.xsd UCSM-IN.xsd:2329:59: warning F001: element 'managedObject' is implicitly of anyType UCSM-IN.xsd:2329:59: info: did you forget to specify 'type' attribute? UCSM-IN.xsd:2393:60: warning F001: element 'externalMethod' is implicitly of anyType UCSM-IN.xsd:2393:60: info: did you forget to specify 'type' attribute? UCSM-IN.xsd:2420:60: warning F001: element 'abstractFilter' is implicitly of anyType UCSM-IN.xsd:2420:60: info: did you forget to specify 'type' attribute? UCSM-IN.xsd: warning T004: generating parsing functions for 733 global elements UCSM-IN.xsd: info: use --root-element-* options to specify document root(s) /cygdrive/d/UCS_Xfer/schema_4.1.2/src/UCSM-IN.hxx: 187066 /cygdrive/d/UCS_Xfer/schema_4.1.2/src/UCSM-IN.cxx: 507208 total: 694274 $ The compile has problems with types with names that match OS-header defined types, even though I've tried to rename them (I think) with -custom_type. $ gcc -c -I . UCSM-IN.cxx In file included from UCSM-IN.cxx:41: UCSM-IN.hxx:1575:9: error: `timezone_xs' does not name a type; did you mean `timezone'? 1575 | typedef timezone_xs timezone; | ^~~~~~~~~~~ | timezone UCSM-IN.hxx:1729:9: error: `select_xs' does not name a type; did you mean `selector'? 1729 | typedef select_xs select; | ^~~~~~~~~ | selector UCSM-IN.hxx:1821:9: error: `clock_xs' does not name a type; did you mean `clock_t'? 1821 | typedef clock_xs clock; | ^~~~~~~~ | clock_t In file included from UCSM-IN.cxx:41: UCSM-IN.hxx:113000:13: error: `timezone' in namespace `::' does not name a type 113000 | typedef ::timezone timezone_type; | ^~~~~~~~ In file included from /usr/include/time.h:153, from /usr/include/pthread.h:14, from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/x86_64-pc-cygwin/bits/gth r-default.h:35, from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/x86_64-pc-cygwin/bits/gth r.h:148, from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/ext/atomicity.h:35, from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/bits/basic_string.h:39, from /usr/lib/gcc/x86_64-pc-cygwin/10/include/c++/string:55, from /usr/include/xsd/cxx/xml/char-utf8.hxx:9, from UCSM-IN.hxx:67, from UCSM-IN.cxx:41: /usr/include/cygwin/time.h:33:13: note: `timezone' declared here 33 | extern long timezone __asm__ (_SYMSTR (_timezone)); | ^~~~~~~~ In file included from UCSM-IN.cxx:41: UCSM-IN.hxx:113005:39: error: `timezone_type' was not declared in this scope; did you mean `timezone'? 113005 | typedef ::xsd::cxx::tree::optional< timezone_type > timezone_optional; | ^~~~~~~~~~~~~ | timezone ... I'm using: gcc version 10.2.0 (GCC) CodeSynthesis XSD XML Schema to C++ compiler 4.0.0 What have I missed? This can't be that uncommon, but I haven't found anything in the archives or documentation. Any suggestions? From boris at codesynthesis.com Fri Jul 23 05:39:12 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Jul 23 05:38:09 2021 Subject: [xsd-users] OS-defined type names conflict with schema type names In-Reply-To: <027214b6-4881-7700-ac85-7cb6fece9d9a@simonsontech.net> References: <027214b6-4881-7700-ac85-7cb6fece9d9a@simonsontech.net> Message-ID: Dave Simonson writes: > The compile has problems with types with names that match OS-header > defined types, even though I've tried to rename them (I think) with > -custom_type. The option you are looking for is --reserved-name: --reserved-name n[=r] Add name n to the list of names that should not be used as identifiers. The name can optionally be followed by = and the replacement name r that should be used instead. All the C++ keywords are already in this list.