Daniel P. Berrangé <berra...@redhat.com> writes: > On Mon, Aug 05, 2024 at 03:11:12PM +0200, Markus Armbruster wrote: >> Daniel P. Berrangé <berra...@redhat.com> writes: >> >> > On Mon, Aug 05, 2024 at 02:22:47PM +0200, Markus Armbruster wrote: >> >> Daniel P. Berrangé <berra...@redhat.com> writes: >> >> >> >> > This allows us to include multiple QAPI schemas in the same file. >> >> > >> >> > Signed-off-by: Daniel P. Berrangé <berra...@redhat.com> >> >> >> >> I figure you had reason to simultaneously include headers generated for >> >> multiple schemas. Do tell :) >> > >> > I didn't want to have this patch, but the unit tests do this :-( >> > >> > [2/37] Compiling C object >> > tests/libtestqapi.a.p/meson-generated_.._test-qapi-commands-sub-sub-module.c.o >> > FAILED: >> > tests/libtestqapi.a.p/meson-generated_.._test-qapi-commands-sub-sub-module.c.o >> > >> > cc -m64 -Itests/libtestqapi.a.p -Itests -I../tests -I. -Iqapi -Itrace -Iui >> > -Iui/shader -Itests/include -I/usr/include/glib-2.0 >> > -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 >> > -fdiagnostics-color=auto -Wall -Winvalid-pch -Werror -std=gnu11 -O2 -g >> > -fstack-protector-strong -Wempty-body -Wendif-labels >> > -Wexpansion-to-defined -Wformat-security -Wformat-y2k -Wignored-qualifiers >> > -Wimplicit-fallthrough=2 -Winit-self -Wmissing-format-attribute >> > -Wmissing-prototypes -Wnested-externs -Wold-style-declaration >> > -Wold-style-definition -Wredundant-decls -Wshadow=local >> > -Wstrict-prototypes -Wtype-limits -Wundef -Wvla -Wwrite-strings >> > -Wno-missing-include-dirs -Wno-psabi -Wno-shift-negative-value -isystem >> > /var/home/berrange/src/virt/qemu/linux-headers -isystem linux-headers >> > -iquote . -iquote /var/home/berrange/src/virt/qemu -iquote >> > /var/home/berrange/src/virt/qemu/include -iquote >> > /var/home/berrange/src/virt/qemu/host/include/x86_64 -iquote >> > /var/home/berrange/src/virt/qemu/host/include/generic -iquote >> > /var/home/berrange/src/virt/qemu/tcg/i386 -pthread -msse2 -mcx16 >> > -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE >> > -fno-strict-aliasing -fno-common -fwrapv -ftrivial-auto-var-init=zero >> > -fzero-call-used-regs=used-gpr -fPIE -MD -MQ >> > tests/libtestqapi.a.p/meson-generated_.._test-qapi-commands-sub-sub-module.c.o >> > -MF >> > tests/libtestqapi.a.p/meson-generated_.._test-qapi-commands-sub-sub-module.c.o.d >> > -o >> > tests/libtestqapi.a.p/meson-generated_.._test-qapi-commands-sub-sub-module.c.o >> > -c tests/test-qapi-commands-sub-sub-module.c >> > In file included from tests/test-qapi-types-sub-sub-module.h:17, >> > from tests/test-qapi-visit-sub-sub-module.h:17, >> > from tests/test-qapi-commands-sub-sub-module.c:19: >> > tests/test-qapi-features.h:16:5: error: redeclaration of enumerator >> > ‘QAPI_FEATURE_DEPRECATED’ >> > 16 | QAPI_FEATURE_DEPRECATED, >> > | ^~~~~~~~~~~~~~~~~~~~~~~ >> > In file included from ./qapi/qapi-types-error.h:17, >> > from >> > /var/home/berrange/src/virt/qemu/include/qapi/error.h:275, >> > from >> > /var/home/berrange/src/virt/qemu/include/qapi/compat-policy.h:16, >> > from tests/test-qapi-commands-sub-sub-module.c:14: >> > ./qapi/qapi-features.h:16:5: note: previous definition of >> > ‘QAPI_FEATURE_DEPRECATED’ with type ‘enum <anonymous>’ >> > 16 | QAPI_FEATURE_DEPRECATED, >> > | ^~~~~~~~~~~~~~~~~~~~~~~ >> > ninja: build stopped: subcommand failed. >> > make[1]: *** [Makefile:167: run-ninja] Error 1 >> > make[1]: Leaving directory '/var/home/berrange/src/virt/qemu/build' >> > make: *** [GNUmakefile:6: build] Error 2 >> >> Compiles for me with PATCH 5/6 taken out. What am I doing wrong? > > The bit in patch 6 which generates the enum still has the prefix: > > + self._genh.add("typedef enum {\n") > + for name in features: > + self._genh.add(f" {c_enum_const(self._prefix + > 'QAPI_FEATURE', name)},\n") > + > + self._genh.add("} " + c_name(self._prefix + 'QapiFeature') + ";\n")
Alright, I got it to fail with the appended patch. I'll have a closer look. Thanks! [...] diff --git a/scripts/qapi/features.py b/scripts/qapi/features.py index 9b77be6310..1eb0c8a8ac 100644 --- a/scripts/qapi/features.py +++ b/scripts/qapi/features.py @@ -55,9 +55,9 @@ def visit_end(self) -> None: self._genh.add("typedef enum {\n") for name in features: - self._genh.add(f" {c_enum_const(self._prefix + 'QAPI_FEATURE', name)},\n") + self._genh.add(f" {c_enum_const('QAPI_FEATURE', name)},\n") - self._genh.add("} " + c_name(self._prefix + 'QapiFeature') + ";\n") + self._genh.add("} " + c_name('QapiFeature') + ";\n") def _record(self, features: List[QAPISchemaFeature]): for f in features: