On Thu, Feb 12, 2026 at 01:20:18PM +0800, Kevin J. McCarthy wrote:
> 
> The ones in wchar.h include wcrtomb(), mbrtowc(), and wcwidth().
> 
> So, in this case, why are we only getting in trouble with wcwidth(), but
> not the first two?
> 

FreeBSD defines wcwidth as __wcwidth [1] and has in a different header the 
complete implementation of __wcwidth so that it can always be inlined [2]. An 
undef wcwidth solves the problem.

Honestly, wchar.h and wctype.h are nowadays part of POSIX and the C standard, 
and have been for a long time. The workaround isn't really needed anymore. If 
somebody disagrees, they should step up and maintain the code. Your limited 
time is better spend elsewhere.

Maybe this excerpt from POSIX is the reason for the weirdness in the source 
code?

  "The iswblank() function was a late addition to the ISO C standard and was 
introduced at the same time as the ISO C standard introduced <wctype.h>, which 
contains all of the isw*() functions. The Open Group Base Specifications had 
previously aligned with the MSE working draft and had introduced the rest of 
the isw*() functions into <wchar.h>. For backwards-compatibility, the original 
set of isw*() functions, without iswblank(), are permitted (as an XSI 
extension) in <wchar.h>. For maximum portability, applications should include 
<wctype.h> in order to obtain declarations for the isw*() functions."[3]

Best regards,
Daniel

[1]: https://cgit.freebsd.org/src/tree/include/wchar.h#n221
[2]: https://cgit.freebsd.org/src/tree/include/_ctype.h#n157
[3]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/wchar.h.html

Reply via email to