Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

incompatible pointer type

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
Zucca
Moderator
Moderator
User avatar
Posts: 4691
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

incompatible pointer type

  • Quote

Post by Zucca » Fri Mar 13, 2026 9:54 am

I'm trying to build chocobar on a arm64 using llvm profile.

Code: Select all

 ./build.sh
++ dirname -- ./build.sh
+ cd .
+ bin=chocobar-9999
+ : /var/tmp/portage/gui-apps/chocobar-9999/image/usr
+ : /var/tmp/portage/gui-apps/chocobar-9999/image/bin
+ CFLAGS='-march=armv8.6-a -mcpu=apple-m2 -O2 -Wall -Wextra -Wno-unused-function -Wno-unused-parameter'
+ PKG_CONFIG=pkg-config
++ pkg-config --variable=pkgdatadir wayland-protocols
+ WAYLAND_PROTOCOLS=//usr/share/wayland-protocols
++ pkg-config --variable=wayland_scanner wayland-scanner
+ WAYLAND_SCANNER=/usr/bin/wayland-scanner
+ PKGS='wayland-client pixman-1 fcft'
++ pkg-config --cflags wayland-client pixman-1 fcft
+ CFLAGS='-march=armv8.6-a -mcpu=apple-m2 -O2 -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -I/usr/lib64/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DUTF8PROC_EXPORTS -I/usr/include/pixman-1'
++ pkg-config --libs wayland-client pixman-1 fcft
+ LDLIBS=' -lwayland-client -lm -lfcft -lpixman-1'
+ '[' 0 -gt 0 ']'
+ '[' -z ']'
+ for protocol in single-pixel-buffer-v1 viewporter wlr-layer-shell-unstable-v1 xdg-shell xdg-foreign-unstable-v2
+ '[' -e single-pixel-buffer-v1-protocol.c -a -e single-pixel-buffer-v1-protocol.h ']'
+ protocolxml=protocols/single-pixel-buffer-v1.xml
+ '[' '!' -e protocols/single-pixel-buffer-v1.xml ']'
+ for protocolxml in "$WAYLAND_PROTOCOLS"/*/*/"$protocol".xml
+ break
+ /usr/bin/wayland-scanner private-code //usr/share/wayland-protocols/staging/single-pixel-buffer/single-pixel-buffer-v1.xml single-pixel-buffer-v1-protocol.c
+ /usr/bin/wayland-scanner client-header //usr/share/wayland-protocols/staging/single-pixel-buffer/single-pixel-buffer-v1.xml single-pixel-buffer-v1-protocol.h
+ for protocol in single-pixel-buffer-v1 viewporter wlr-layer-shell-unstable-v1 xdg-shell xdg-foreign-unstable-v2
+ '[' -e viewporter-protocol.c -a -e viewporter-protocol.h ']'
+ protocolxml=protocols/viewporter.xml
+ '[' '!' -e protocols/viewporter.xml ']'
+ for protocolxml in "$WAYLAND_PROTOCOLS"/*/*/"$protocol".xml
+ break
+ /usr/bin/wayland-scanner private-code //usr/share/wayland-protocols/stable/viewporter/viewporter.xml viewporter-protocol.c
+ /usr/bin/wayland-scanner client-header //usr/share/wayland-protocols/stable/viewporter/viewporter.xml viewporter-protocol.h
+ for protocol in single-pixel-buffer-v1 viewporter wlr-layer-shell-unstable-v1 xdg-shell xdg-foreign-unstable-v2
+ '[' -e wlr-layer-shell-unstable-v1-protocol.c -a -e wlr-layer-shell-unstable-v1-protocol.h ']'
+ protocolxml=protocols/wlr-layer-shell-unstable-v1.xml
+ '[' '!' -e protocols/wlr-layer-shell-unstable-v1.xml ']'
+ /usr/bin/wayland-scanner private-code protocols/wlr-layer-shell-unstable-v1.xml wlr-layer-shell-unstable-v1-protocol.c
+ /usr/bin/wayland-scanner client-header protocols/wlr-layer-shell-unstable-v1.xml wlr-layer-shell-unstable-v1-protocol.h
+ for protocol in single-pixel-buffer-v1 viewporter wlr-layer-shell-unstable-v1 xdg-shell xdg-foreign-unstable-v2
+ '[' -e xdg-shell-protocol.c -a -e xdg-shell-protocol.h ']'
+ protocolxml=protocols/xdg-shell.xml
+ '[' '!' -e protocols/xdg-shell.xml ']'
+ for protocolxml in "$WAYLAND_PROTOCOLS"/*/*/"$protocol".xml
+ break
+ /usr/bin/wayland-scanner private-code //usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.c
+ /usr/bin/wayland-scanner client-header //usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml xdg-shell-protocol.h
+ for protocol in single-pixel-buffer-v1 viewporter wlr-layer-shell-unstable-v1 xdg-shell xdg-foreign-unstable-v2
+ '[' -e xdg-foreign-unstable-v2-protocol.c -a -e xdg-foreign-unstable-v2-protocol.h ']'
+ protocolxml=protocols/xdg-foreign-unstable-v2.xml
+ '[' '!' -e protocols/xdg-foreign-unstable-v2.xml ']'
+ for protocolxml in "$WAYLAND_PROTOCOLS"/*/*/"$protocol".xml
+ break
+ /usr/bin/wayland-scanner private-code //usr/share/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml xdg-foreign-unstable-v2-protocol.c
+ /usr/bin/wayland-scanner client-header //usr/share/wayland-protocols/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml xdg-foreign-unstable-v2-protocol.h
+ '[' -e /var/tmp/portage/gui-apps/chocobar-9999/image/bin ']'
+ mkdir -p /var/tmp/portage/gui-apps/chocobar-9999/image/bin
+ cc chocobar.c single-pixel-buffer-v1-protocol.c util.c viewporter-protocol.c wlr-layer-shell-unstable-v1-protocol.c xdg-foreign-unstable-v2-protocol.c xdg-shell-protocol.c -march=armv8.6-a -mcpu=apple-m2 -O2 -Wall -Wextra -Wno-unused-function -Wno-unused-parameter -I/usr/lib64/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -DUTF8PROC_EXPORTS -I/usr/include/pixman-1 -lwayland-client -lm -lfcft -lpixman-1 -o /var/tmp/portage/gui-apps/chocobar-9999/image/bin/chocobar-9999
In file included from chocobar.c:11:
drwl/drwl.h: In function ‘drwl_init’:
drwl/drwl.h:88:9: warning: ‘fcft_set_scaling_filter’ is deprecated [-Wdeprecated-declarations]
   88 |         fcft_set_scaling_filter(FCFT_SCALING_FILTER_LANCZOS3);
      |         ^~~~~~~~~~~~~~~~~~~~~~~
In file included from drwl/drwl.h:33:
/usr/include/fcft/fcft.h:190:6: note: declared here
  190 | bool fcft_set_scaling_filter(enum fcft_scaling_filter filter) FCFT_DEPRECATED;
      |      ^~~~~~~~~~~~~~~~~~~~~~~
chocobar.c: At top level:
chocobar.c:287:18: error: initialization of ‘void (*)(void *, struct wl_surface *, struct wl_output *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  287 |         .enter = noop,
      |                  ^~~~
chocobar.c:287:18: note: (near initialization for ‘ss_surface_listener.enter’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:288:18: error: initialization of ‘void (*)(void *, struct wl_surface *, struct wl_output *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  288 |         .leave = noop,
      |                  ^~~~
chocobar.c:288:18: note: (near initialization for ‘ss_surface_listener.leave’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:290:39: error: initialization of ‘void (*)(void *, struct wl_surface *, uint32_t)’ {aka ‘void (*)(void *, struct wl_surface *, unsigned int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  290 |         .preferred_buffer_transform = noop,
      |                                       ^~~~
chocobar.c:290:39: note: (near initialization for ‘ss_surface_listener.preferred_buffer_transform’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:663:18: error: initialization of ‘void (*)(void *, struct wl_surface *, struct wl_output *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  663 |         .enter = noop,
      |                  ^~~~
chocobar.c:663:18: note: (near initialization for ‘so_surface_listener.enter’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:664:18: error: initialization of ‘void (*)(void *, struct wl_surface *, struct wl_output *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  664 |         .leave = noop,
      |                  ^~~~
chocobar.c:664:18: note: (near initialization for ‘so_surface_listener.leave’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:665:35: error: initialization of ‘void (*)(void *, struct wl_surface *, int32_t)’ {aka ‘void (*)(void *, struct wl_surface *, int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  665 |         .preferred_buffer_scale = noop,
      |                                   ^~~~
chocobar.c:665:35: note: (near initialization for ‘so_surface_listener.preferred_buffer_scale’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:666:39: error: initialization of ‘void (*)(void *, struct wl_surface *, uint32_t)’ {aka ‘void (*)(void *, struct wl_surface *, unsigned int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  666 |         .preferred_buffer_transform = noop,
      |                                       ^~~~
chocobar.c:666:39: note: (near initialization for ‘so_surface_listener.preferred_buffer_transform’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:755:21: error: initialization of ‘void (*)(void *, struct wl_output *, int32_t,  int32_t,  int32_t,  int32_t,  int32_t,  const char *, const char *, int32_t)’ {aka ‘void (*)(void *, struct wl_output *, int,  int,  int,  int,  int,  const char *, const char *, int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  755 |         .geometry = noop,
      |                     ^~~~
chocobar.c:755:21: note: (near initialization for ‘output_listener.geometry’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:756:17: error: initialization of ‘void (*)(void *, struct wl_output *, uint32_t,  int32_t,  int32_t,  int32_t)’ {aka ‘void (*)(void *, struct wl_output *, unsigned int,  int,  int,  int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  756 |         .mode = noop,
      |                 ^~~~
chocobar.c:756:17: note: (near initialization for ‘output_listener.mode’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:757:17: error: initialization of ‘void (*)(void *, struct wl_output *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  757 |         .done = noop,
      |                 ^~~~
chocobar.c:757:17: note: (near initialization for ‘output_listener.done’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:758:18: error: initialization of ‘void (*)(void *, struct wl_output *, int32_t)’ {aka ‘void (*)(void *, struct wl_output *, int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  758 |         .scale = noop,
      |                  ^~~~
chocobar.c:758:18: note: (near initialization for ‘output_listener.scale’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:759:24: error: initialization of ‘void (*)(void *, struct wl_output *, const char *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  759 |         .description = noop,
      |                        ^~~~
chocobar.c:759:24: note: (near initialization for ‘output_listener.description’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:969:26: error: initialization of ‘void (*)(void *, struct wl_pointer *, uint32_t,  int32_t)’ {aka ‘void (*)(void *, struct wl_pointer *, unsigned int,  int)’} from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  969 |         .axis_value120 = noop,
      |                          ^~~~
chocobar.c:969:26: note: (near initialization for ‘pointer_listener.axis_value120’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
chocobar.c:991:17: error: initialization of ‘void (*)(void *, struct wl_seat *, const char *)’ from incompatible pointer type ‘void (*)(void)’ [-Wincompatible-pointer-types]
  991 |         .name = noop,
      |                 ^~~~
chocobar.c:991:17: note: (near initialization for ‘seat_listener.name’)
chocobar.c:164:13: note: ‘noop’ declared here
  164 | static void noop(){}
      |             ^~~~
Is llvm/clang just very cautious here? Does chocobar.c have bad programing practices?
I'm not a C programmer, but these errors indicate that some pointers aren't correctly initialized, so the compiler errors out instead of trying to guess and possible make insecure binary.
..: Zucca :..

Code: Select all

init=/sbin/openrc-init
-systemd -logind -elogind seatd
I am NaN! I am a man!
Top
John R. Graham
Administrator
Administrator
User avatar
Posts: 10898
Joined: Tue Mar 08, 2005 3:39 pm
Location: Somewhere over Winder, Georgia, USA

  • Quote

Post by John R. Graham » Fri Mar 13, 2026 12:49 pm

Way back in the C89/C90 standard (and before), this construct wasn't even a warning. I believe that in C99 it became a warning and, at some point thereafter, an error. You might be able to Band-Aid this by specifying application-targeted CFLAGS containing "-std=C89" (or maybe a later version where only warnings would be thrown).

Defining a function like

Code: Select all

void myfunc() {};
classically meant the function was defined without a "prototype": function pointers with prototype information could be assigned a pointer to a prototype-less function, but you can probably see the possibilities for problems this looseness allows.

- John
Last edited by John R. Graham on Fri Mar 13, 2026 12:55 pm, edited 2 times in total.
I can confirm that I have received between 0 and 499 National Security Letters.
Top
grknight
Retired Dev
Retired Dev
Posts: 2557
Joined: Fri Feb 20, 2015 9:36 pm

  • Quote

Post by grknight » Fri Mar 13, 2026 12:52 pm

https://wiki.gentoo.org/wiki/Modern_C_porting
Top
Hu
Administrator
Administrator
Posts: 24385
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Fri Mar 13, 2026 1:20 pm

The Wiki page that grknight linked is a good primer. For this specific case, the solution is a bit easier. Based on the name of the function (noop) and its definition that the compiler printed in the diagnostic, we can tell that the author wants a function which does nothing and returns nothing. It exists solely to avoid putting nullptr in the function pointer field, presumably because the caller assumes that the pointer can always be called and does not have a special case to skip calling a pointer that is equal to nullptr. Therefore, the spot fix is to change the prototype of noop to match the prototype the compiler wants. This is slightly complicated by the fact that the author uses noop with several different prototypes. If I were to write a minimal fix, I would:
  • Notify upstream. This needs to be fixed everywhere, not just in Gentoo.
  • While waiting, remove the definition of noop, and add definitions such as:

    Code: Select all

    static void noop_1(void *, struct wl_output *) {}
    static void noop_2(void *, struct wl_output *, const char *) {}
    static void noop_3(void *, struct wl_output *, int32_t) {}
    static void noop_4(void *, struct wl_output *, int32_t,  int32_t,  int32_t,  int32_t,  int32_t,  const char *, const char *, int32_t) {}
    static void noop_5(void *, struct wl_output *, uint32_t,  int32_t,  int32_t,  int32_t) {}
    static void noop_6(void *, struct wl_pointer *, uint32_t,  int32_t) {}
    static void noop_7(void *, struct wl_seat *, const char *) {}
    static void noop_8(void *, struct wl_surface *, int32_t) {}
    static void noop_9(void *, struct wl_surface *, struct wl_output *) {}
    static void noop_10(void *, struct wl_surface *, uint32_t) {}
    
  • Then use each noop_N in the corresponding initialization. You can work from the compiler error messages shown to find which is which, or rely on the fact that if you get it right, the warning will go away without needing a cast. You want the initialization lines to read like:

    Code: Select all

    .preferred_buffer_transform = noop_10,
Better names than noop_N would make this more readable. I didn't want to try embedding argument-specific decorations into each name. That is left as an exercise for the reader. ;)

Post back if you need more help.
Top
Zucca
Moderator
Moderator
User avatar
Posts: 4691
Joined: Thu Jun 14, 2007 10:31 pm
Location: Rasi, Finland
Contact:
Contact Zucca
Website

  • Quote

Post by Zucca » Sun Mar 15, 2026 12:57 pm

So I had some time to dig into this again.
I'll raise an issue to upstream.

Chocobar uses drwl header library... but an older version.
The newest version of drwl is incompatible with chocobar. That also might need an issue to be raised.

Meanwhile I'll use

Code: Select all

CFLAGS="${CFLAGS} -Wno-error=incompatible-pointer-types"
... until upstream makes a fix.
..: Zucca :..

Code: Select all

init=/sbin/openrc-init
-systemd -logind -elogind seatd
I am NaN! I am a man!
Top
Post Reply

5 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic