Hi Felix,
The attached patch makes xlib compile with GCC 14, which probably will
be shipped with the next Debian release. GCC 14 sets
-Werror=incompatible-pointer-types by default, and xlib triggers some
warnings which are now considered errors.
The patch was tested with the following compilers, xlib versions and
systems:
GCC 10.2.1 (Debian bullseye, xlib 1.7.2)
GCC 12.2.0 (Debian bookworm, xlib 1.8.4)
GCC 14.2.0 (Debian trixie, 1.8.10)
TCC 0.9.27 (Debian bookworm, Debian trixie)
I've also tested the compiled library with
https://github.com/mario-goulart/nsfwm and it seems to work fine (though
that application might not exercise the code affected by the patch).
All the best.
Mario
--
http://parenteses.org/mario
diff --git a/xlib-original.scm b/xlib-original.scm
index 4182b048..80b943f1 100644
--- a/xlib-original.scm
+++ b/xlib-original.scm
@@ -58,7 +58,7 @@
(foreign-function xcreatewindow ((POINTER STRUCT) UNSIGNED-LONG INT INT UNSIGNED-INT UNSIGNED-INT UNSIGNED-INT INT UNSIGNED-INT (POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) UNSIGNED-LONG "XCreateWindow")
(foreign-function xlistinstalledcolormaps ((POINTER STRUCT) UNSIGNED-LONG (POINTER INT)) (POINTER UNSIGNED-LONG) "XListInstalledColormaps")
(foreign-function xlistfonts ((POINTER STRUCT) STRING INT (POINTER INT)) (POINTER (POINTER CHAR)) "XListFonts")
-(foreign-function xlistfontswithinfo ((POINTER STRUCT) STRING INT (POINTER INT) (POINTER (POINTER STRUCT))) (POINTER (POINTER CHAR)) "XListFontsWithInfo")
+(foreign-function xlistfontswithinfo ((POINTER STRUCT) STRING INT (POINTER INT) (POINTER (POINTER "XFontStruct"))) (POINTER (POINTER "XFontStruct")) "XListFontsWithInfo")
(foreign-function xgetfontpath ((POINTER STRUCT) (POINTER INT)) (POINTER (POINTER CHAR)) "XGetFontPath")
(foreign-function xlistextensions ((POINTER STRUCT) (POINTER INT)) (POINTER (POINTER CHAR)) "XListExtensions")
(foreign-function xlistproperties ((POINTER STRUCT) UNSIGNED-LONG (POINTER INT)) (POINTER UNSIGNED-LONG) "XListProperties")
@@ -74,7 +74,7 @@
(foreign-function xvisualidfromvisual ((POINTER STRUCT)) UNSIGNED-LONG "XVisualIDFromVisual")
(foreign-function xinitextension ((POINTER STRUCT) STRING) (POINTER STRUCT) "XInitExtension")
(foreign-function xaddextension ((POINTER STRUCT)) (POINTER STRUCT) "XAddExtension")
-(foreign-function xfindonextensionlist ((POINTER (POINTER STRUCT)) INT) (POINTER STRUCT) "XFindOnExtensionList")
+(foreign-function xfindonextensionlist ((POINTER (POINTER "XExtData")) INT) (POINTER STRUCT) "XFindOnExtensionList")
;(foreign-function xeheadofextensionlist (***INVALID***) (POINTER (POINTER STRUCT)) "XEHeadOfExtensionList")
(foreign-function xrootwindow ((POINTER STRUCT) INT) UNSIGNED-LONG "XRootWindow")
(foreign-function xdefaultrootwindow ((POINTER STRUCT)) UNSIGNED-LONG "XDefaultRootWindow")
@@ -116,7 +116,7 @@
(foreign-function xactivatescreensaver ((POINTER STRUCT)) INT "XActivateScreenSaver")
(foreign-function xaddhost ((POINTER STRUCT) (POINTER STRUCT)) INT "XAddHost")
(foreign-function xaddhosts ((POINTER STRUCT) (POINTER STRUCT) INT) INT "XAddHosts")
-(foreign-function xaddtoextensionlist ((POINTER (POINTER STRUCT)) (POINTER STRUCT)) INT "XAddToExtensionList")
+(foreign-function xaddtoextensionlist ((POINTER (POINTER "struct _XExtData")) (POINTER STRUCT)) INT "XAddToExtensionList")
(foreign-function xaddtosaveset ((POINTER STRUCT) UNSIGNED-LONG) INT "XAddToSaveSet")
(foreign-function xalloccolor ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XAllocColor")
(foreign-function xalloccolorcells ((POINTER STRUCT) UNSIGNED-LONG INT (POINTER UNSIGNED-LONG) UNSIGNED-INT (POINTER UNSIGNED-LONG) UNSIGNED-INT) INT "XAllocColorCells")
@@ -355,23 +355,23 @@
(foreign-function xsetlocalemodifiers (c-string) xstring* "XSetLocaleModifiers")
(foreign-function xcreatefontset ((POINTER STRUCT) STRING (POINTER (POINTER (POINTER CHAR))) (POINTER INT) (POINTER (POINTER CHAR))) (POINTER STRUCT) "XCreateFontSet")
(foreign-function xfreefontset ((POINTER STRUCT) (POINTER STRUCT)) VOID "XFreeFontSet")
-(foreign-function xfontsoffontset ((POINTER STRUCT) (POINTER (POINTER (POINTER STRUCT))) (POINTER (POINTER (POINTER CHAR)))) INT "XFontsOfFontSet")
+(foreign-function xfontsoffontset ((POINTER STRUCT) (POINTER (POINTER (POINTER "XFontStruct"))) (POINTER (POINTER (POINTER CHAR)))) INT "XFontsOfFontSet")
(foreign-function xbasefontnamelistoffontset ((POINTER STRUCT)) (POINTER CHAR) "XBaseFontNameListOfFontSet")
(foreign-function xlocaleoffontset ((POINTER STRUCT)) (POINTER CHAR) "XLocaleOfFontSet")
(foreign-function xcontextdependentdrawing ((POINTER STRUCT)) INT "XContextDependentDrawing")
(foreign-function xextentsoffontset ((POINTER STRUCT)) (POINTER STRUCT) "XExtentsOfFontSet")
(foreign-function xmbtextescapement ((POINTER STRUCT) STRING INT) INT "XmbTextEscapement")
-(foreign-function xwctextescapement ((POINTER STRUCT) (POINTER UNSIGNED-CHAR) INT) INT "XwcTextEscapement")
+(foreign-function xwctextescapement ((POINTER STRUCT) (CONST (POINTER "wchar_t")) INT) INT "XwcTextEscapement")
(foreign-function xmbtextextents ((POINTER STRUCT) STRING INT (POINTER STRUCT) (POINTER STRUCT)) INT "XmbTextExtents")
-(foreign-function xwctextextents ((POINTER STRUCT) (POINTER UNSIGNED-CHAR) INT (POINTER STRUCT) (POINTER STRUCT)) INT "XwcTextExtents")
+(foreign-function xwctextextents ((POINTER STRUCT) (CONST (POINTER "wchar_t")) INT (POINTER STRUCT) (POINTER STRUCT)) INT "XwcTextExtents")
(foreign-function xmbtextpercharextents ((POINTER STRUCT) STRING INT (POINTER STRUCT) (POINTER STRUCT) INT (POINTER INT) (POINTER STRUCT) (POINTER STRUCT)) INT "XmbTextPerCharExtents")
-(foreign-function xwctextpercharextents ((POINTER STRUCT) (POINTER UNSIGNED-CHAR) INT (POINTER STRUCT) (POINTER STRUCT) INT (POINTER INT) (POINTER STRUCT) (POINTER STRUCT)) INT "XwcTextPerCharExtents")
+(foreign-function xwctextpercharextents ((POINTER STRUCT) (CONST (POINTER "wchar_t")) INT (POINTER STRUCT) (POINTER STRUCT) INT (POINTER INT) (POINTER STRUCT) (POINTER STRUCT)) INT "XwcTextPerCharExtents")
(foreign-function xmbdrawtext ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) INT INT (POINTER STRUCT) INT) VOID "XmbDrawText")
(foreign-function xwcdrawtext ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) INT INT (POINTER STRUCT) INT) VOID "XwcDrawText")
(foreign-function xmbdrawstring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT STRING INT) VOID "XmbDrawString")
-(foreign-function xwcdrawstring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT (POINTER UNSIGNED-CHAR) INT) VOID "XwcDrawString")
+(foreign-function xwcdrawstring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT (CONST (POINTER "wchar_t")) INT) VOID "XwcDrawString")
(foreign-function xmbdrawimagestring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT STRING INT) VOID "XmbDrawImageString")
-(foreign-function xwcdrawimagestring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT (POINTER UNSIGNED-CHAR) INT) VOID "XwcDrawImageString")
+(foreign-function xwcdrawimagestring ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER STRUCT) INT INT (CONST (POINTER "wchar_t")) INT) VOID "XwcDrawImageString")
(foreign-function xopenim ((POINTER STRUCT) (POINTER STRUCT) (POINTER CHAR) (POINTER CHAR)) (POINTER STRUCT) "XOpenIM")
(foreign-function xcloseim ((POINTER STRUCT)) INT "XCloseIM")
; XGetIMValues
@@ -388,7 +388,7 @@
(foreign-function ximofic ((POINTER STRUCT)) (POINTER STRUCT) "XIMOfIC")
(foreign-function xfilterevent ((POINTER UNION) UNSIGNED-LONG) INT "XFilterEvent")
(foreign-function xmblookupstring ((POINTER STRUCT) (POINTER STRUCT) STRING INT (POINTER UNSIGNED-LONG) (POINTER INT)) INT "XmbLookupString")
-(foreign-function xwclookupstring ((POINTER STRUCT) (POINTER STRUCT) (POINTER UNSIGNED-CHAR) INT (POINTER UNSIGNED-LONG) (POINTER INT)) INT "XwcLookupString")
+(foreign-function xwclookupstring ((POINTER STRUCT) (POINTER STRUCT) (POINTER "wchar_t") INT (POINTER UNSIGNED-LONG) (POINTER INT)) INT "XwcLookupString")
; XVaCreateNestedList
(foreign-function xallocclasshint () (POINTER STRUCT) "XAllocClassHint")
(foreign-function xallociconsize () (POINTER STRUCT) "XAllocIconSize")
@@ -404,9 +404,9 @@
(foreign-function xequalregion ((POINTER STRUCT) (POINTER STRUCT)) INT "XEqualRegion")
(foreign-function xfindcontext ((POINTER STRUCT) UNSIGNED-LONG INT (POINTER (POINTER CHAR))) INT "XFindContext")
(foreign-function xgetclasshint ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XGetClassHint")
-(foreign-function xgeticonsizes ((POINTER STRUCT) UNSIGNED-LONG (POINTER (POINTER STRUCT)) (POINTER INT)) INT "XGetIconSizes")
+(foreign-function xgeticonsizes ((POINTER STRUCT) UNSIGNED-LONG (POINTER (POINTER "XIconSize")) (POINTER INT)) INT "XGetIconSizes")
(foreign-function xgetnormalhints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XGetNormalHints")
-(foreign-function xgetrgbcolormaps ((POINTER STRUCT) UNSIGNED-LONG (POINTER (POINTER STRUCT)) (POINTER INT) UNSIGNED-LONG) INT "XGetRGBColormaps")
+(foreign-function xgetrgbcolormaps ((POINTER STRUCT) UNSIGNED-LONG (POINTER (POINTER "XStandardColormap")) (POINTER INT) UNSIGNED-LONG) INT "XGetRGBColormaps")
(foreign-function xgetsizehints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) UNSIGNED-LONG) INT "XGetSizeHints")
(foreign-function xgetstandardcolormap ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) UNSIGNED-LONG) INT "XGetStandardColormap")
(foreign-function xgettextproperty ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) UNSIGNED-LONG) INT "XGetTextProperty")
@@ -415,8 +415,8 @@
(foreign-function xgetwmhints ((POINTER STRUCT) UNSIGNED-LONG) (POINTER STRUCT) "XGetWMHints")
(foreign-function xgetwmiconname ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XGetWMIconName")
(foreign-function xgetwmname ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XGetWMName")
-(foreign-function xgetwmnormalhints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER INT)) INT "XGetWMNormalHints")
-(foreign-function xgetwmsizehints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER INT) UNSIGNED-LONG) INT "XGetWMSizeHints")
+(foreign-function xgetwmnormalhints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER LONG)) INT "XGetWMNormalHints")
+(foreign-function xgetwmsizehints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT) (POINTER LONG) UNSIGNED-LONG) INT "XGetWMSizeHints")
(foreign-function xgetzoomhints ((POINTER STRUCT) UNSIGNED-LONG (POINTER STRUCT)) INT "XGetZoomHints")
(foreign-function xintersectregion ((POINTER STRUCT) (POINTER STRUCT) (POINTER STRUCT)) INT "XIntersectRegion")
(foreign-function xlookupstring ((POINTER STRUCT) STRING INT (POINTER UNSIGNED-LONG) (POINTER STRUCT)) INT "XLookupString")
@@ -448,11 +448,11 @@
(foreign-function xstringlisttotextproperty ((POINTER (POINTER CHAR)) INT (POINTER STRUCT)) INT "XStringListToTextProperty")
(foreign-function xsubtractregion ((POINTER STRUCT) (POINTER STRUCT) (POINTER STRUCT)) INT "XSubtractRegion")
(foreign-function xmbtextlisttotextproperty ((POINTER STRUCT) (POINTER (POINTER CHAR)) INT INT (POINTER STRUCT)) INT "XmbTextListToTextProperty")
-(foreign-function xwctextlisttotextproperty ((POINTER STRUCT) (POINTER (POINTER UNSIGNED-CHAR)) INT INT (POINTER STRUCT)) INT "XwcTextListToTextProperty")
-(foreign-function xwcfreestringlist ((POINTER (POINTER UNSIGNED-CHAR))) VOID "XwcFreeStringList")
+(foreign-function xwctextlisttotextproperty ((POINTER STRUCT) (POINTER (POINTER "wchar_t")) INT INT (POINTER STRUCT)) INT "XwcTextListToTextProperty")
+(foreign-function xwcfreestringlist ((POINTER (POINTER "wchar_t"))) VOID "XwcFreeStringList")
(foreign-function xtextpropertytostringlist ((POINTER STRUCT) (POINTER (POINTER (POINTER CHAR))) (POINTER INT)) INT "XTextPropertyToStringList")
(foreign-function xmbtextpropertytotextlist ((POINTER STRUCT) (POINTER STRUCT) (POINTER (POINTER (POINTER CHAR))) (POINTER INT)) INT "XmbTextPropertyToTextList")
-(foreign-function xwctextpropertytotextlist ((POINTER STRUCT) (POINTER STRUCT) (POINTER (POINTER (POINTER UNSIGNED-CHAR))) (POINTER INT)) INT "XwcTextPropertyToTextList")
+(foreign-function xwctextpropertytotextlist ((POINTER STRUCT) (POINTER STRUCT) (POINTER (POINTER (POINTER "wchar_t"))) (POINTER INT)) INT "XwcTextPropertyToTextList")
(foreign-function xunionrectwithregion ((POINTER STRUCT) (POINTER STRUCT) (POINTER STRUCT)) INT "XUnionRectWithRegion")
(foreign-function xunionregion ((POINTER STRUCT) (POINTER STRUCT) (POINTER STRUCT)) INT "XUnionRegion")
(foreign-function xwmgeometry ((POINTER STRUCT) INT STRING STRING UNSIGNED-INT (POINTER STRUCT) (POINTER INT) (POINTER INT) (POINTER INT) (POINTER INT) (POINTER INT)) INT "XWMGeometry")
diff --git a/xlib.scm b/xlib.scm
index 34917d5b..570a00f5 100644
--- a/xlib.scm
+++ b/xlib.scm
@@ -28,6 +28,7 @@
(define-for-syntax (xlate-type t cn)
(match (strip-syntax t) ; punt
+ [('CONST t) `(const ,(xlate-type t cn))]
[('POINTER 'FUNCTION) (xlate-warn t 'c-pointer cn)]
[('POINTER (or 'STRUCT 'UNION 'VOID)) 'c-pointer]
[('POINTER (? string? s)) `(c-pointer ,s)]