Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cessenat opened this issue Jul 24, 2024 · 7 comments

Comments

@cessenat
Copy link

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
Copy link
Owner

eserte commented Jul 24, 2024

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
Copy link
Owner

eserte commented Jul 24, 2024

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

@wlmb
Copy link

wlmb commented Sep 4, 2024

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

@wlmb
Copy link

wlmb commented Sep 4, 2024

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
Copy link
Author

cessenat commented Sep 4, 2024

-Wincompatible-pointer-types

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

@wlmb
Copy link

wlmb commented Sep 4, 2024

Didn't help :(

@Tux
Copy link
Contributor

Tux commented Mar 14, 2025

Chicken out: add -Wno-error=incompatible-pointer-types to the CCFLAGS definitions in Makefile and pTk/Makefile.
It is still wrong, but now there is no need to revert to gcc-13 or dig into the errors yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants