Incompatible function pointer types

I’m getting the same error in two places using a lambda function as an argument to GLib.List.foreach.

error: incompatible function pointer types passing 'void (gconstpointer, gpointer)' (aka 'void (const void *, void *)') to parameter of type 'GFunc' (aka 'void (*)(void *, void *)')
// in my subclass of AdwApplication
        private void on_quit () {
            this.get_windows ().foreach ((obj) => {
                var win = (Vapad.Window) obj;
                win.close_all ();

Is this something I’m doing subtly wrong so that it works sometimes, or is it likely a compiler bug?

Interesting. I set CC to gcc before running Meson and it compiles and runs.

Likely the same issue of this: clang-16 fails to compile due to signature mismatch of TestDataFunc() glib-2.0 API (#1413) · Issues · GNOME / vala · GitLab

Seems like it, and then last comment on the issue sounds like they’re on the track.

This problem is not isolated to the binding of GTestDataFunc and will require picking up any const qualifier of C type declarations.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.