Re: BUG #18995: Building with GCC 14 fails: incompatible pointer struct pam_message

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Watkins <awatkins1966@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2025-07-23T18:41:02Z
Lists: pgsql-bugs

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix build breakage on Solaris-alikes with late-model GCC.

Andrew Watkins <awatkins1966@gmail.com> writes:
>  You are right Solaris is missing "const"

> struct pam_conv {
>         int (*conv)(int, struct pam_message **, struct pam_response **,
> void *);
>         void *appdata_ptr;
> };

So I tried to replicate this issue on an OpenIndiana VM (OI 2024.04),
and got no failure.  Digging into /usr/include/security/pam_appl.h,
I found the reason:

struct pam_conv {
#ifdef _PAM_LEGACY_NONCONST
        int (*conv)(int, struct pam_message **,
#else
        int (*conv)(int, const struct pam_message **,
#endif
            struct pam_response **, void *);
        void *appdata_ptr;              /* Application data ptr */
};

So that's just annoying as all get-out: it means some "Solaris"
platforms do have this declaration with the "const", and even
there it's going to be dependent on compilation environment.

I still see a way to avoid a configure check though: let's make
src/include/port/solaris.h "#define _PAM_LEGACY_NONCONST".
That should make OpenIndiana enough like other Solaris-alikes
for the purpose, and we can also use that same symbol to cue
our code how to declare the callback function.

Or we could create a configure check, but that seems like a lot
of work, and it would add some extra time to everybody's build.

			regards, tom lane