Re: [Lcms-user] LCMS 2.20 missing definition of WCHAR_MAX
An ICC-based CMM for color management
Brought to you by:
mm2
|
From: Philip R. <phi...@or...> - 2026-11-14 22:47:06
|
Sounds good to me. Thanks, -phil. On 11/14/26 12:42 AM, Marti Maria wrote: > ZjQcmQRYFpfptBannerEnd > > Hi Phil, > > Thanks for reporting. You’re right, this needs to be fixed on the > LittleCMS side. > > This is a subtle portability bug. LittleCMS was implicitly assuming > that WCHAR_MAX would be defined through standard headers such as > stddef.h or limits.h, while the C99 and C11 standards actually specify > it in stdint.h, where its definition is conditional. > > To complicate matters, older versions of Visual C++ did not provide > stdint.h until Visual Studio 2010, and there are still projects using > those older compilers that LittleCMS tries to support. > > I'm sorry about this, and I apologize for not testing it more > carefully before releasing 2.20. > > I think the cleanest fix would be to replace the WCHAR_MAX > preprocessor check with a regular C condition using |sizeof(wchar_t) > == 4|. This would distinguish between 16-bit and 32-bit wchar_t > implementations on our supported platforms without depending on any > particular header or compiler version. Since sizeof is a compile-time > constant, the compiler should optimize away the unused branch. > > Does this approach sound reasonable to you? > > Best regards, > Marti > > >> On 13 Nov 2026, at 23:18, Philip Race <phi...@or...> wrote: >> >> Hi Marti, >> >> We are integrating 2.20 into OpenJDK mainline and cmstypes.c now has this >> >> + #if (WCHAR_MAX > 0xFFFF) // WCHAR_MAX support is >> required for C99 >> >> We use C11 .. so that ought not to be a problem but our build fails with >> >> cmstypes.c:164:14: error: "WCHAR_MAX" is not defined, evaluates to 0 >> [-Werror=undef] >> 164 | #if (WCHAR_MAX > 0xFFFF) // WCHAR_MAX support is required for C99 >> | ^~~~~~~~~ >> cc1: all warnings being treated as errors >> >> So far as I can see nothing in LittleCMS actually includes wchar.h >> which would define it. >> >> It seems likely that without the definition and no checking for >> warnings the resulting build may corrupt some strings. >> >> We may work around this on our end by adding the include but I think >> something needs to be fixed on the LittleCMS end .. >> >> JDK bug details here https://bugs.openjdk.org/browse/JDK-8396577 >> >> -phil >> >> > |