eserte / perl-tk

the perl module Tk
https://metacpan.org/release/Tk
Other
44 stars 31 forks source link

An incompatible-pointer-types in pTk/Xlib.t that induces an error with gcc 14 #106

Open cessenat opened 1 month ago

cessenat commented 1 month ago

In file pTk/Xlib.t line 334 there is VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, unsigned int, int))) which, at compile time, induces with gcc 11.3 on Ubuntu 22.04

x86_64-linux-gnu-gcc -c  -I..  -I. -Ibitmaps  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g   -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.34/CORE"    Xlib_f.c
In file included from Xlib_f.c:17:
Xlib.t:334:1: warning: ‘XKeycodeToKeysym’ is deprecated [-Wdeprecated-declarations]
  334 | VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, unsigned int, int)))
      | ^~~~~
In file included from Xlib_f.c:4:
/usr/include/X11/Xlib.h:1687:15: note: declared here
 1687 | extern KeySym XKeycodeToKeysym(
      |               ^~~~~~~~~~~~~~~~
Xlib.t:334:14: warning: initialization of ‘KeySym (*)(Display *, unsigned int,  int)’ {aka ‘long unsigned int (*)(Display *, unsigned int,  int)’} from incompatible pointer type ‘KeySym (*)(Display *, KeyCode,  int)’ {aka ‘long unsigned int (*)(Display *, unsigned char,  int)’} [-Wincompatible-pointer-types]
  334 | VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, unsigned int, int)))
      |              ^~~~~~~~~~~~~~~~

while with gcc 14.1 on Fedora 40 the warning is now en error.

Therefore I would suggest to write instead VFUNC(KeySym,XKeycodeToKeysym,V_XKeycodeToKeysym,_ANSI_ARGS_((Display *, unsigned char, int))) to correct that. What do you think @eserte ? Thanks.

eserte commented 1 month ago

Theoretically yes. However, Xlib.t seems to be generated somehow, using the script pTk/mkVFunc it seems, and I have to figure out how this is supposed to work.

eserte commented 1 month ago

Probably the change needs to be made in pTk/Xlib.h. pTk/Xlib.t will be generated from it.

wlmb commented 1 week ago

I have a similar problem with gcc 14.2, I can't 'make'. Any suggestion?

wlmb commented 1 week ago
The error I get is cc -c -I/usr/include/freetype2 -I.. -I/usr/include/freetype2 -I. -Ibitmaps -I/usr/include/freetype2 -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -DVERSION=\"804.036\" -DXS_VERSION=\"804.036\" -fPIC "-I/home/mochan/perl5/perlbrew/perls/perl-5.36.0/lib/5.36.0/x86_64-linux/CORE" tkCanvText.ctkCanvText.c: In function ‘GetTextIndex’: tkCanvText.c:1253:40: error: passing argument 2 of ‘TcldeclsVptr->V_Tcl_GetStringFromObj’ from incompatible pointer type [-Wincompatible-pointer-types] 1253 string = Tcl_GetStringFromObj(obj, &length); ^~~
size_t {aka long unsigned int }

tkCanvText.c:1253:40: note: expected ‘int ’ but argument is of type ‘size_t ’ {aka ‘long unsigned int *’}

cessenat commented 1 week ago

-Wincompatible-pointer-types

For that specific issue you can try to compile with the GCC compiler option -Wincompatible-pointer-types

wlmb commented 1 week ago

Didn't help :(