xiaoxiang781216 commented on code in PR #6200:
URL: https://github.com/apache/incubator-nuttx/pull/6200#discussion_r865648395


##########
libs/libc/misc/lib_impure.c:
##########
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * libs/libc/misc/lib_impure.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
+ ****************************************************************************/
+
+#if defined(__has_include)

Review Comment:
   > Yes. Sorry, I made an unclear comment. I mean the content of this file 
`__sFILE_fake`, `_ATTRIBUTE((weak))` is GCC specific. 
   
   __sFILE_fake isn't gcc specific, it's libc specific which come from newlib:
   
https://github.com/mirror/newlib-cygwin/blob/master/newlib/libc/include/sys/reent.h
   
https://github.com/mirror/newlib-cygwin/blob/master/newlib/libc/reent/impure.c
   
   Or do you mean that `# if __has_include(<reent.h>)` will be true only for 
GCC?
   
   Let's summary:
   
   1. __has_include is defined by new c/c++ standard
   2. reent.h and __sFILE_fake come from newlib
   
   Why we need care about newlib? Since nuttx doesn't provide all c/c++ 
library(libc, partial libm and libc++), which mean we have to mix use libraries 
from nuttx and toolchain:
   
   1. libc always use nuttx
   2. libm either nuttx or toolchain
   3. libgcc always use toolchain
   4. libsupc++ either nuttx(libcxxaib) or toolchain
   5. libgcov always from toolchain
   
   Since some library(at least libm, libsupc++ and libgcov) call printf or 
access errno in their source, and build with newlib, we have to provide some 
dummy newlib definition to make linker happy. The better method is to built 
these library with nuttx's libc by ourself, but we have to keep this hack 
before this happen.
   
   note:
   
   1. All most embedded toolchain(gcc and clang) bundle with newlib
   2. libgcc, libsupc++ and libgcov is part of gcc and clang, not newlib, 
glibc, musl.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to