MB_LEN_MAX conflict between gcc's limits.h and newlib's sys/config.h

J. Johnston jjohnstn@redhat.com
Fri Sep 6 09:04:00 GMT 2002


Joern Rennecke wrote:
> 
> gcc.dg/bitfld-4.c gets a macro redefinition warning for MB_LEN_MAX,
> because first gcc's limits.h is included, which defines MB_LEN_MAX to 1,
> and then newlib's stdio.h is included, which includes _ansi.h, which
> in turn includes sys/config.h, which defines MB_LEN_MAX to 8.
> --
> --------------------------
> SuperH (UK) Ltd.
> 2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
> T:+44 1454 462330

Two issues.  

First of all, the value has been removed from newlib's sys/config.h header file.
It should not have been there.

The second issue is that the gcc default value does not consider that multibyte
support may exist.  According to ANSI, the value of MB_CUR_MAX (which
is found in stdlib.h) is never larger than MB_LEN_MAX.  This isn't true
as MB_CUR_MAX can be set up to 8 for Japanese JIS, for example, when
newlib is configured with the --enable-newlib-mb option.  Perhaps gcc
could look for this configuration option when building a cross-compiler and
set MB_LEN_MAX appropriately.

-- Jeff J.



More information about the Newlib mailing list