mirror of
https://github.com/apache/nuttx.git
synced 2026-05-11 16:01:03 +08:00
219a5ce09e
include/cxx contains NuttX's mini C++ ABI shims and must only be added to the include path when CONFIG_LIBMINIABI is selected. tools/Config.mk was adding it unconditionally for every non-LIBCXX/non-UCLIBCXX build, and the platform.cmake files for arm, arm64, risc-v, x86_64 and tricore were adding it inside the CONFIG_LIBCXXTOOLCHAIN block. With an unpatched downloaded ARM GNU Toolchain, <cstdlib> uses newlib's stdlib.h, defining div_t as an anonymous struct. A later inclusion of NuttX's stdlib.h via <cstdio>->stdio.h->kmalloc.h then redefines div_t with struct tag div_s, causing a conflicting declaration error. Guard the div_t/ldiv_t/lldiv_t definitions in stdlib.h with redefinitions when a toolchain stdlib.h was already processed. Also fix lldiv_s members typed as long instead of long long. Signed-off-by: trns1997 <trns1997@gmail.com>