[PATCH] frontend: guard setlocale() consistently with its include
"Maya R. Odinezenko via Lame-dev" <[email protected]> Thu, 16 Jul 2026 15:50:00 -0400
| Newsgroups | gmane.comp.audio.mp3.lame |
|---|---|
| Message-ID | <CAFCgL3njcwAE-VmDwjOpiyX3Lj-p74Gv_mr0f0eE9UU4YjNdYg@mail.gmail.com> |
Hello, Building the 4.0 release on macOS (Apple silicon, Apple clang 21) stops in the frontend: frontend/parse.c:1623:5: error: use of undeclared identifier 'setlocale' frontend/parse.c:1623:15: error: use of undeclared identifier 'LC_CTYPE' This configuration has HAVE_LANGINFO_H but not HAVE_ICONV. parse.c includes <locale.h> only when both are defined, while the setlocale() call checks HAVE_LANGINFO_H alone, so the call compiles without the declaration of setlocale() or the definition of LC_CTYPE. In this build the shipped configure script (generated by Autoconf 2.73) selected -std=gnu23, and Apple clang 21 reports both missing names as errors. The patch below gives the call the same guard as the existing include, which is the smallest change; including <locale.h> more broadly would be another possible fix if you would rather keep the call active in iconv-less builds. Verified locally: the pristine 4.0 tree fails as above, and the patched tree builds and encodes. The patch is against current trunk (r6586) and also applies to the 4.0 release (offset -33 lines). Maya -- >8 -- From: Maya <[email protected]> Date: Thu, 16 Jul 2026 15:28:13 -0400 Subject: [PATCH] frontend: guard setlocale() consistently with its include parse.c includes <locale.h> only when both HAVE_ICONV and HAVE_LANGINFO_H are defined, but the setlocale(LC_CTYPE, "") call at the top of parse_args() checks HAVE_LANGINFO_H alone. In a configuration that has langinfo.h but not iconv, the call therefore compiles without the declaration of setlocale() or the definition of LC_CTYPE. Seen building the 4.0 release on macOS: the shipped configure (generated by Autoconf 2.73) selected -std=gnu23 in this build, and Apple clang 21 reports both missing names as errors, so the frontend fails to build. Give the call the same guard as the existing include. --- frontend/parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/parse.c b/frontend/parse.c index 94c7e95..85128b2 100644 --- a/frontend/parse.c +++ b/frontend/parse.c @@ -1652,7 +1652,7 @@ parse_args_(lame_global_flags * gfp, int argc, char **argv, enum TextEncoding id3_tenc = TENC_LATIN1; #endif -#ifdef HAVE_LANGINFO_H +#if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H) setlocale(LC_CTYPE, ""); #endif inPath[0] = '\0';