public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jianghua Yang <[email protected]>
To: [email protected]
Subject: [PATCH] Fix build failure on macOS 26.2 SDK due to missing nl_langinfo_l declaration
Date: Thu, 19 Mar 2026 11:06:17 -0700
Message-ID: <CAAZLFmS6_si5W8LqSynj5J1uK6Xhe5Q7Ucg7LE1PZ8OqO9kvCA@mail.gmail.com> (raw)

Hi,

  Building PostgreSQL against the macOS 26.2 SDK (Xcode 26 beta) fails
  with the following error:

    src/port/chklocale.c:326:8: error: call to undeclared function
    'nl_langinfo_l'; ISO C99 and later do not support implicit function
    declarations [-Wimplicit-function-declaration]
        sys = nl_langinfo_l(CODESET, loc);

  == Root Cause ==

  macOS 26.2 SDK changed the structure of <langinfo.h>.  In previous
  SDK versions, nl_langinfo_l() was declared unconditionally.  In the
  new SDK, it is only exposed when _USE_EXTENDED_LOCALES_ is defined,
  guarded behind a conditional include of <xlocale/_langinfo.h>:

    /* macOS 26.2 SDK: langinfo.h */
    #include <_langinfo.h>          /* nl_langinfo() only */

    #ifdef _USE_EXTENDED_LOCALES_
    #include <xlocale/_langinfo.h>  /* nl_langinfo_l() */
    #endif

  PostgreSQL's chklocale.c only includes <langinfo.h> directly, so
  nl_langinfo_l() is no longer visible on macOS 26.2.

  == Fix ==

  Include <xlocale.h> explicitly on Apple platforms.  This header
  declares nl_langinfo_l() unconditionally and is the standard way
  to access locale-specific extensions on macOS.

  Tested on macOS 26.2 (darwin 25.3) with Apple Clang 17.

  Patch attached.

  Regards,
  Jianghua Yang


Attachments:

  [application/octet-stream] 0001-Fix-build-failure-on-macOS-26.2-SDK-due-to-missing-n.patch (1.1K, 3-0001-Fix-build-failure-on-macOS-26.2-SDK-due-to-missing-n.patch)
  download | inline diff:
From c1be5a32e8e9d130592355c97ebc89ddc5e81d7d Mon Sep 17 00:00:00 2001
From: Jianghua Yang <[email protected]>
Date: Thu, 19 Mar 2026 10:59:11 -0700
Subject: [PATCH] Fix build failure on macOS 26.2 SDK due to missing
 nl_langinfo_l declaration

macOS 26.2 SDK changed langinfo.h to only expose nl_langinfo_l() when
_USE_EXTENDED_LOCALES_ is defined, via xlocale/_langinfo.h.  Previous
SDK versions exposed it unconditionally.  This caused a build error in
chklocale.c:

  error: call to undeclared function 'nl_langinfo_l'

Fix by explicitly including <xlocale.h> on Apple platforms, which
declares nl_langinfo_l() regardless of _USE_EXTENDED_LOCALES_.
---
 src/port/chklocale.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/port/chklocale.c b/src/port/chklocale.c
index 664eeab9050..4428b99d79e 100644
--- a/src/port/chklocale.c
+++ b/src/port/chklocale.c
@@ -21,6 +21,9 @@
 
 #ifndef WIN32
 #include <langinfo.h>
+#ifdef __APPLE__
+#include <xlocale.h>				/* provides nl_langinfo_l on macOS */
+#endif
 #endif
 
 #include "mb/pg_wchar.h"
-- 
2.50.1 (Apple Git-155)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] Fix build failure on macOS 26.2 SDK due to missing nl_langinfo_l declaration
  In-Reply-To: <CAAZLFmS6_si5W8LqSynj5J1uK6Xhe5Q7Ucg7LE1PZ8OqO9kvCA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox