This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e26e2a7b94b834dfc248a0df73d3d3f245794ffd Author: Alan Carvalho de Assis <[email protected]> AuthorDate: Sun Oct 18 08:39:48 2026 -0300 libs/libc: ctype: add CONFIG_LIBC_CTYPE_TABLE The newlib compatible character class table (_ctype_) was only built for the toolchain C++ library (GNU libstdc++). Pre-built libraries compiled against the newlib headers need it too, since the newlib ctype.h macros reference it. The character class macros are defined by ctype.h for the toolchain C++ library. Check whether _U is already defined instead of repeating the ctype.h condition (CONFIG_LIBCXXTOOLCHAIN), so that lib_ctype.c follows ctype.h if that condition ever changes. Signed-off-by: Alan Carvalho de Assis <[email protected]> Assisted-by: Claude Code Opus 5.5 --- libs/libc/Kconfig | 1 + libs/libc/ctype/Kconfig | 13 +++++++++++++ libs/libc/ctype/lib_ctype.c | 24 ++++++++++++++---------- libs/libxx/Kconfig | 1 + 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/libs/libc/Kconfig b/libs/libc/Kconfig index 2df4cbbfd03..d96ac214c27 100644 --- a/libs/libc/Kconfig +++ b/libs/libc/Kconfig @@ -5,6 +5,7 @@ comment "Standard C Library Options" +source "libs/libc/ctype/Kconfig" source "libs/libc/stdio/Kconfig" source "libs/libc/audio/Kconfig" source "libs/libc/machine/Kconfig" diff --git a/libs/libc/ctype/Kconfig b/libs/libc/ctype/Kconfig new file mode 100644 index 00000000000..8fcfbbd05a9 --- /dev/null +++ b/libs/libc/ctype/Kconfig @@ -0,0 +1,13 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config LIBC_CTYPE_TABLE + bool + default n + ---help--- + Provide the newlib compatible character class table (_ctype_). + It is needed by the toolchain C++ library (GNU libstdc++) and by + pre-built libraries compiled against the newlib headers, whose + ctype.h macros reference it. diff --git a/libs/libc/ctype/lib_ctype.c b/libs/libc/ctype/lib_ctype.c index 29ab6c66bb9..1b8817d393a 100644 --- a/libs/libc/ctype/lib_ctype.c +++ b/libs/libc/ctype/lib_ctype.c @@ -32,12 +32,15 @@ * Macro Definitions ****************************************************************************/ -#ifndef CONFIG_LIBCXXTOOLCHAIN +#ifdef CONFIG_LIBC_CTYPE_TABLE -/* MSVC seems to conflict with these macros if defined in the public area. - * As such, they are defined in the private section to let NuttX build +/* These macros may already be defined by ctype.h (e.g. for the toolchain + * C++ library). Otherwise they are defined here: MSVC seems to conflict + * with them if defined in the public area. */ +#ifndef _U + #define _U 01 #define _L 02 #define _N 04 @@ -47,15 +50,16 @@ #define _X 0100 #define _B 0200 -#else +#endif /**************************************************************************** - * Private Types + * Public Data ****************************************************************************/ -/* GNU libstdc++ is expecting an array _ctype_ to be defined. This array - * is usually defined in GNU libc or newlib. - * Here the system support only basic ASCII locale. +/* The newlib compatible character class table. GNU libstdc++ and the + * pre-built libraries compiled against newlib (whose ctype.h macros use + * it) expect this array to be defined. It is usually defined in GNU libc + * or newlib. Here the system support only basic ASCII locale. */ const char _ctype_[] = @@ -96,8 +100,8 @@ const char _ctype_[] = }; /**************************************************************************** - * Private Functions + * Public Functions ****************************************************************************/ -#endif +#endif /* CONFIG_LIBC_CTYPE_TABLE */ diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index 44d582b2ed2..ea650b8f6eb 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -32,6 +32,7 @@ config LIBCXXNONE config LIBCXXTOOLCHAIN bool "Toolchain C++ support" select HAVE_CXXINITIALIZE + select LIBC_CTYPE_TABLE ---help--- Use Standard C++ library from toolchain.
