This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit eac66d76b3ca9a0a9d05b54169af8f2579b63442
Author: Xiang Xiao <[email protected]>
AuthorDate: Mon Jun 1 14:19:26 2020 +0800

    lib/stdlib: Change some macro to inline function
    
    to avoid the build break for "using ::xxx"
    
    Signed-off-by: Xiang Xiao <[email protected]>
    Change-Id: Ib5d861a6c2b9e6ba585df83b3cdff8a3e1495bce
---
 include/stdlib.h | 47 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index 004fe01..388cb85 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -158,7 +158,15 @@ int       on_exit(CODE void (*func)(int, FAR void *), FAR 
void *arg);
 /* _Exit() is a stdlib.h equivalent to the unistd.h _exit() function */
 
 void      _exit(int status); /* See unistd.h */
-#define   _Exit(s) _exit(s)
+
+#ifdef __cplusplus
+inline void _Exit(int s)
+{
+  _exit(s);
+}
+#else
+#define _Exit(s) _exit(s)
+#endif
 
 /* System() command is not implemented in the NuttX libc because it is so
  * entangled with shell logic.  There is an experimental version at
@@ -187,13 +195,44 @@ double    strtod(FAR const char *str, FAR char **endptr);
 long double strtold(FAR const char *str, FAR char **endptr);
 #endif
 
-#define atoi(nptr)  ((int)strtol((nptr), NULL, 10))
-#define atol(nptr)  strtol((nptr), NULL, 10)
+#ifdef __cplusplus
+inline int atoi(FAR const char *nptr)
+{
+  return (int)strtol(nptr, NULL, 10);
+}
+#else
+#define atoi(nptr) ((int)strtol((nptr), NULL, 10))
+#endif
+
+#ifdef __cplusplus
+inline int atol(FAR const char *nptr)
+{
+  return strtol(nptr, NULL, 10);
+}
+#else
+#define atol(nptr) strtol((nptr), NULL, 10)
+#endif
+
 #ifdef CONFIG_HAVE_LONG_LONG
+#ifdef __cplusplus
+inline long long atoll(FAR const char *nptr)
+{
+  return strtoll(nptr, NULL, 10);
+}
+#else
 #define atoll(nptr) strtoll((nptr), NULL, 10)
 #endif
+#endif
+
 #ifdef CONFIG_HAVE_DOUBLE
-#define atof(nptr)  strtod((nptr), NULL)
+#ifdef __cplusplus
+inline double atof(FAR const char *nptr)
+{
+  return strtod(nptr, NULL);
+}
+#else
+#define atof(nptr) strtod((nptr), NULL)
+#endif
 #endif
 
 /* Binary to string conversions */

Reply via email to