On Thu, Aug 05, 2021 at 11:00:24PM -0400, Eduardo Habkost wrote:
> Hello,
> 
> I'm looking for help dealing with a naming conflict when building
> QEMU for Windows hosts.
> 
> The summary is: I'm trying to replace the ACCEL() macro in
> include/qemu/accel.h with an inline function, but the ACCEL name
> conflicts with a symbol provided by winuser.h:
> 
>   In file included from /builds/ehabkost/qemu/include/exec/memory.h:28,
>                    from /builds/ehabkost/qemu/hw/ppc/mac.h:30,
>                    from ../hw/pci-host/uninorth.c:27:
>   /builds/ehabkost/qemu/include/qemu/accel.h:63:45: error: 'ACCEL' redeclared 
> as different kind of symbol
>      63 | OBJECT_DECLARE_TYPE(AccelState, AccelClass, ACCEL)
>         |                                             ^~~~~
>   /builds/ehabkost/qemu/include/qom/object.h:178:5: note: in definition of 
> macro 'DECLARE_INSTANCE_CHECKER'
>     178 |     OBJ_NAME(const void *obj) \
>         |     ^~~~~~~~
>   /builds/ehabkost/qemu/include/qom/object.h:240:5: note: in expansion of 
> macro 'DECLARE_OBJ_CHECKERS'
>     240 |     DECLARE_OBJ_CHECKERS(InstanceType, ClassType, \
>         |     ^~~~~~~~~~~~~~~~~~~~
>   /builds/ehabkost/qemu/include/qemu/accel.h:63:1: note: in expansion of 
> macro 'OBJECT_DECLARE_TYPE'
>      63 | OBJECT_DECLARE_TYPE(AccelState, AccelClass, ACCEL)
>         | ^~~~~~~~~~~~~~~~~~~
>   In file included from 
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/windows.h:72,
>                    from 
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/winsock2.h:23,
>                    from /builds/ehabkost/qemu/include/sysemu/os-win32.h:29,
>                    from /builds/ehabkost/qemu/include/qemu/osdep.h:135,
>                    from ../hw/pci-host/uninorth.c:25:
>   /usr/x86_64-w64-mingw32/sys-root/mingw/include/winuser.h:1757:5: note: 
> previous declaration of 'ACCEL' was here
>    1757 |   } ACCEL,*LPACCEL;
>         |     ^~~~~
>   [338/4278] Compiling C object 
> libqemuutil.a.p/meson-generated_.._trace_trace-scsi.c.obj
>   ninja: build stopped: subcommand failed.
>   make: *** [Makefile:156: run-ninja] Error 1
> 
> (Full log at https://gitlab.com/ehabkost/qemu/-/jobs/1481978645)
> 
> Does anybody more experienced with Win32 have a suggestion on how
> to deal with this?  Do we really need to include winsock2.h /
> windows.h / winuser.h from qemu/osdep.h?

Yep, they're the equivalent of the standard posix headers we would
need on non-Linux.

Windows header files are well known for having many annoyingly common
names used in macros/symbols, so you pretty much just have to rename
whatever is in your app that clashes.

I'd suggest we use  CPUACCEL / CpuAccel  or something like that in
QEMU.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to