wchar_t in inttypes.h and C++

Juli Mallett jmallett at FreeBSD.org
Sun Jan 24 05:13:24 UTC 2010

Hey folks,

The handling of wchar_t in inttypes.h for wcsto*max(3) is currently
broken in C++ where wchar_t is a built-in type and not derived from
__wchar_t.  I have a patch to define wchar_t if it isn't defined in C
and to use wchar_t in the declarations rather than __wchar_t as we do
today, as is done in other headers that declare wchar_t functions.
BDE doesn't like it -- certainly it's unclear that it would be okay
for inttypes.h to define wchar_t in C -- but I'm not sure there's a
markedly-better alternative.

We could define a type ___wchar_t (or something like) that is a
typedef of __wchar_t in C and a typedef of wchar_t in C++.  We could
define wcsto*max(3) differently for C++ and C.  We could declare the
functions as taking wchar_t but only define them if wchar_t has been
defined (or we're compiling for C++).

For the sake of argument, here's the inttypes.h patch that follows the
lead of stdlib.h:



More information about the freebsd-standards mailing list