You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "leducp (via GitHub)" <gi...@apache.org> on 2024/04/24 15:05:20 UTC

[PR] Basic locale support for C++ (libstdc++) [nuttx]

leducp opened a new pull request, #12230:
URL: https://github.com/apache/nuttx/pull/12230

   ## 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 strange behavior which where workaround with a hack (-D_STDLIB_H) in the past.
   
   ## Impact
   
   ## Testing
   On going
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2076749588

   @leducp please sqaush into one patch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578101520


##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   Because I need to enable some wrapping in the C part (C++ depends in the NuttX libc for the locale).
   
   My goal is to enable a few symbols to be built in the NuttX libc if:
     1.  the config enable the C++ library from the toolchain
     2. the toolchain is GCC
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1581120829


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)

Review Comment:
   Test ongoing to be sure nothing is broken



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2075388419

   > > @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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "nicolas71640 (via GitHub)" <gi...@apache.org>.
nicolas71640 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578071896


##########
boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig:
##########


Review Comment:
   To revert to nsh defconfig



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578915329


##########
include/ctype.h:
##########
@@ -397,6 +397,23 @@ int tolower(int c);
 int tolower_l(int c, locale_t locale);
 #endif
 
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)

Review Comment:
   Oh OK I get your point. I wasn't sure about other compilers (since the flag is C++ toolchain and not specifically GCC C++) so I focused on filtering in case of collision with other compilers. If you think that it's OK without precondition the patch will be way simpler :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1579150321


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;

Review Comment:
   ```suggestion
     return MB_CUR_MAX;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2075374645

   @leducp this might potentially close this issue: https://github.com/apache/nuttx/issues/11227


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578101520


##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   Because I need to enable some wrapping in the C part (C++ depends in the NuttX libc for the locale).
   
   My goal is to enable a few symbols to be built in the NuttX libc if:
     1.  the config enables the C++ library from the toolchain
     2. the toolchain is GCC
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578086024


##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   @leducp why to include `-D__LIBCXXTOOLCHAIN__` to ARCHCFLAGS too? Shouldn't ARCHCXXFLAGS be enough?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2075443838

   > > > @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++ 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578424905


##########
include/ctype.h:
##########
@@ -397,6 +397,23 @@ int tolower(int c);
 int tolower_l(int c, locale_t locale);
 #endif
 
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)

Review Comment:
   I don't understand your point? __GNUC__ is defined by GCC to detect that this the compiler in use and __LIBCXXTOOLCHAIN__ is defined by ourself through the Makefile?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #12230:
URL: https://github.com/apache/nuttx/pull/12230


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578101520


##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   Because I need to enable some wrapping in the C part (C++ depends on the NuttX libc for the locale).
   
   My goal is to enable a few symbols to be built in the NuttX libc if:
     1.  the config enables the C++ library from the toolchain
     2. the toolchain is GCC
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "trns1997 (via GitHub)" <gi...@apache.org>.
trns1997 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578088303


##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   I was just wondering, what if we undid the changes from the following MR: https://github.com/apache/nuttx/pull/11812, that means we will go back to just have `set(ARCHCXXFLAGS "-nostdinc++")` for all cxx libs and then use the `CONFIG_LIBCXXTOOLCHAIN` define in the `libs/libc/ctype/lib_locale.c` file instead of defining a new `__LIBCXXTOOLCHAIN__` variable. 



##########
arch/arm/src/cmake/Toolchain.cmake:
##########
@@ -188,7 +188,8 @@ set(ARCHCFLAGS "-Wstrict-prototypes")
 if(NOT CONFIG_LIBCXXTOOLCHAIN)
   set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -nostdinc++")
 else()
-  set(ARCHCXXFLAGS "${ARCHCXXFLAGS} -D_STDLIB_H_")
+  set(ARCHCFLAGS "${ARCHCFLAGS} -D__LIBCXXTOOLCHAIN__")

Review Comment:
   Ah no ignore what i said, we still require what we did before.



##########
boards/arm/xmc4/xmc4800-relax/configs/nsh/defconfig:
##########


Review Comment:
   unstage these changes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578423148


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;
+}
+
+#endif
+
+char *setlocale(int category, const char *locale)
+{
+  if (strcmp (locale, "POSIX") &&
+      strcmp (locale, "C")
+      && strcmp (locale, ""))
+    {
+      return NULL;
+    }
+
+  return "C";
+}
+
+int strcoll(const char *first, const char *second)

Review Comment:
   OK but that's strange: theses symbols are missing if I don't define them... Is there any option that I am missing?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2075381479

   > @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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578764091


##########
include/ctype.h:
##########
@@ -397,6 +397,23 @@ int tolower(int c);
 int tolower_l(int c, locale_t locale);
 #endif
 
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)

Review Comment:
   These functions are always provided by glibc, and are called by many libraries, not only libcxx, so it's better to alwasy implement them without checking some precondition.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1582626769


##########
libs/libc/locale/lib_ctype.c:
##########
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * libs/libc/locale/lib_ctype.c

Review Comment:
   Got it :) !



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2082276985

   let's ignore lvgl ci break which is fixed here: https://github.com/apache/nuttx-apps/pull/2370


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578256858


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;
+}
+
+#endif
+
+char *setlocale(int category, const char *locale)
+{
+  if (strcmp (locale, "POSIX") &&
+      strcmp (locale, "C")
+      && strcmp (locale, ""))
+    {
+      return NULL;
+    }
+
+  return "C";
+}
+
+int strcoll(const char *first, const char *second)

Review Comment:
   already implement in lib_strcoll.c



##########
include/ctype.h:
##########
@@ -397,6 +397,23 @@ int tolower(int c);
 int tolower_l(int c, locale_t locale);
 #endif
 
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)

Review Comment:
   why not directly define these macros



##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;
+}
+
+#endif
+
+char *setlocale(int category, const char *locale)

Review Comment:
   implemented in libs/libc/locale/lib_setlocale.c



##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;
+}
+
+#endif
+
+char *setlocale(int category, const char *locale)
+{
+  if (strcmp (locale, "POSIX") &&
+      strcmp (locale, "C")
+      && strcmp (locale, ""))
+    {
+      return NULL;
+    }
+
+  return "C";
+}
+
+int strcoll(const char *first, const char *second)
+{
+  return strcmp(first, second);
+}
+
+size_t strxfrm(char *destination, const char *source, size_t size)

Review Comment:
   already implement in libs/libc/string/lib_strxfrm.c



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1581205322


##########
libs/libc/locale/lib_ctype.c:
##########
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * libs/libc/locale/lib_ctype.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* 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.
+ */
+
+const char _ctype_[] =

Review Comment:
   _ctye_  need move to libc/ctype/lib_ctype.c, but __locale_mb_cur_max in libc/locale/lib_maxlocale.c



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1581098803


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)

Review Comment:
   it's better to move this function to libc/locale folder and change this file name to lib_ctype.c



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#issuecomment-2075169830

   ping @trns1997 @nicolas71640 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1582626769


##########
libs/libc/locale/lib_ctype.c:
##########
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * libs/libc/locale/lib_ctype.c

Review Comment:
   Got it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1581108037


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)

Review Comment:
   Indeed. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1581733620


##########
libs/libc/locale/lib_ctype.c:
##########
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * libs/libc/locale/lib_ctype.c

Review Comment:
   lib_ctype.c should be located in libs/libc/ctype.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Basic locale support for C++ (libstdc++) [nuttx]

Posted by "leducp (via GitHub)" <gi...@apache.org>.
leducp commented on code in PR #12230:
URL: https://github.com/apache/nuttx/pull/12230#discussion_r1578913294


##########
libs/libc/ctype/lib_locale.c:
##########
@@ -0,0 +1,122 @@
+/****************************************************************************
+ * libs/libc/ctype/lib_locale.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <string.h>
+#include <ctype.h>
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* 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.
+ */
+
+const char _ctype_[] =
+{
+  0,
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _C, _C, _C, _C, _C, _C, _C, _C, \
+  _S | _B,  _P, _P, _P, _P, _P, _P, _P, \
+  _P, _P, _P, _P, _P, _P, _P, _P, \
+  _N, _N, _N, _N, _N, _N, _N, _N, \
+  _N, _N, _P, _P, _P, _P, _P, _P, \
+  _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _U, _U, _U, _U, _U, \
+  _U, _U, _U, _P, _P, _P, _P, _P, \
+  _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _L, _L, _L, _L, _L, \
+  _L, _L, _L, _P, _P, _P, _P, _C, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0, \
+  0,  0,  0,  0,  0,  0,  0,  0
+};
+
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__LIBCXXTOOLCHAIN__) && defined(__GNUC__)
+
+/* GNU libstdc++ is expecting some functions to be defined.
+ */
+
+/* Shall return the max number of bytes of a multibyte character */
+
+int __locale_mb_cur_max(void)
+{
+  return 1;
+}
+
+#endif
+
+char *setlocale(int category, const char *locale)
+{
+  if (strcmp (locale, "POSIX") &&
+      strcmp (locale, "C")
+      && strcmp (locale, ""))
+    {
+      return NULL;
+    }
+
+  return "C";
+}
+
+int strcoll(const char *first, const char *second)

Review Comment:
   OK I missed a config on my side: I'll enabled the minimum locale support of NuttX if C++ toolchain is enabled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org