Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic locale support for C++ (libstdc++) #12230

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

leducp
Copy link
Contributor

@leducp leducp commented Apr 24, 2024

Summary

In order to build C++ stream with GCC libstdc++, a basic locale support is required. This PR add the support for it but in a private manner for now on (standard C locale functions are not exposed yet).

Fix also the build with GCC libstdc++: an include error was leading to stranges behaviors which where workaround with a hack (-D_STDLIB_H) in the past.

Impact

A full C++ code can now be built and executed with LIBCXXTOOLCHAIN with ARM GCC, including std::stringstream (cf. #11227).

Testing

On xmc4 with an std::stringstream to format a complex object.

@leducp
Copy link
Contributor Author

leducp commented Apr 24, 2024

ping @trns1997 @nicolas71640

@trns1997
Copy link
Contributor

trns1997 commented Apr 24, 2024

@leducp this might potentially close this issue: #11227 , i'll try on a board and then we can update the summary to close this issue :)

@leducp
Copy link
Contributor Author

leducp commented Apr 24, 2024

@leducp this might potentially close this issue: #11227 , i'll try on a board and then we can update the summary to close this issue :)

Mmm it solves the problem but not with LLVM libcxx, so i'm not sure if this can be considered a fix for this specific issue. But for sure it at least solves the general problem to use full C++ standard library on NuttX.

@trns1997
Copy link
Contributor

@leducp this might potentially close this issue: #11227 , i'll try on a board and then we can update the summary to close this issue :)

Mmm it solves the problem but not with LLVM libcxx, so i'm not sure if this can be considered a fix for this specific issue. But for sure it at least solves the general problem to use full C++ standard library on NuttX.

In that case a small mention for future users who fail to use sstream because of llvm.

@trns1997
Copy link
Contributor

@leducp this might potentially close this issue: #11227 , i'll try on a board and then we can update the summary to close this issue :)

Mmm it solves the problem but not with LLVM libcxx, so i'm not sure if this can be considered a fix for this specific issue. But for sure it at least solves the general problem to use full C++ standard library on NuttX.

In that case a small mention for future users who fail to use sstream because of llvm.

@leducp i can confirm that stringstream works with libstdc++ and locale support, but it does not work with llvm. Therefore if users want to use stringstream we could recommend them to use gcc libstdc++

include/ctype.h Outdated Show resolved Hide resolved
libs/libc/ctype/lib_locale.c Outdated Show resolved Hide resolved
libs/libc/ctype/lib_locale.c Outdated Show resolved Hide resolved
libs/libc/ctype/lib_locale.c Outdated Show resolved Hide resolved
@leducp leducp marked this pull request as ready for review April 25, 2024 08:12
@xiaoxiang781216
Copy link
Contributor

@leducp please sqaush into one patch.

boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig Outdated Show resolved Hide resolved
arch/arm/src/cmake/Toolchain.cmake Outdated Show resolved Hide resolved
@leducp leducp force-pushed the gcc_cpp_support_locale branch 3 times, most recently from 31582e4 to b536dcb Compare April 26, 2024 15:05
@leducp leducp force-pushed the gcc_cpp_support_locale branch 2 times, most recently from e58da05 to cd21971 Compare April 26, 2024 16:17
…rk for simple cases (POSIX / C locale).

Fix build with C++ GCC toolchain
@xiaoxiang781216
Copy link
Contributor

let's ignore lvgl ci break which is fixed here: apache/nuttx-apps#2370

@xiaoxiang781216 xiaoxiang781216 merged commit 3dc6b4c into apache:master Apr 29, 2024
23 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stringstream linker problem when Normal, Full Optimization Activated
5 participants