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

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


The following commit(s) were added to refs/heads/master by this push:
     new 2820444284d include/cxx/cmath: Use toolchain <cmath> with toolchain 
libm.
2820444284d is described below

commit 2820444284d2e674f7ad7613c7d82f170f111dcf
Author: aviralgarg05 <[email protected]>
AuthorDate: Mon Feb 9 23:58:53 2026 +0530

    include/cxx/cmath: Use toolchain <cmath> with toolchain libm.
    
    When CONFIG_LIBM_TOOLCHAIN is enabled, include_next the 
toolchain\n<c\+\+>/cmath wrapper instead of importing symbols from the 
NuttX\ncmath shim. This avoids include-order recursion and lets 
libstdc\+\+\nresolve std::abs/std::acos/... against the matching toolchain 
C\nmath.h declarations.\n\nKeep the existing NuttX cmath namespace path 
unchanged for non-\ntoolchain libm configurations.
    
    Signed-off-by: aviralgarg05 <[email protected]>
---
 include/cxx/cmath | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/cxx/cmath b/include/cxx/cmath
index 314f0900ac1..719e625324f 100644
--- a/include/cxx/cmath
+++ b/include/cxx/cmath
@@ -30,7 +30,16 @@
 #include <nuttx/config.h>
 #include <nuttx/compiler.h>
 
-#include <math.h>
+#if defined(CONFIG_LIBM_TOOLCHAIN)
+/* In toolchain libm mode, use toolchain <cmath> so it can include_next the
+ * matching C math.h header and populate std::* consistently.
+ */
+
+#  include_next <cmath>
+
+#else
+
+#  include <math.h>
 
 #undef signbit
 #undef fpclassify
@@ -222,4 +231,6 @@ namespace std
 
 }
 
+#endif
+
 #endif // __INCLUDE_CXX_CMATH

Reply via email to