Redefinition of CreateWindow on Windows platform
In the process of updating the conda-forge build of libX11 to version 1.8.4, I think we have discovered a bug in the X.org proto packages that is at least 18 years old (!).
We got a compile error in the Windows build of this form:
../../include/X11/Xlibint.h:542:9: error: 'xCreateWindowAReq' undeclared (first use in this function)
What seems to be going on is that in 1.8.4, Xlibint.h
now includes Xthreads.h
, which on Windows includes the Windows OS headers via Xwindows.h
. The Windows OS API has a function called CreateWindow
that appears to actually be a #define
mapping to the true symbol CreateWindowA
.
The Xwindows.h
header seems to attempt to fix this, but it does so incorrectly. Here's the relevant line:
https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/blame/master/include/X11/Xwindows.h#L89
This is #undef CreateWindowA
, but as far as I can convince myself, it should be #undef CreateWindow
. Patching our libX11 build to do this undef does indeed fix the builds. It seems that the only uses of the CreateWindow
symbol in libX11 have been places where windows.h
never got included, so this issue was hidden for a long time. The change to Xlibint.h
in 1.8.4 mentioned above has exposed the problem, but the actual problem lies in Xwindows.h
.
I can file a merge request to fix this issue, but I just wanted to raise an issue first in case there is any discussion to be had about the diagnosis here.