[libcxx-commits] [libcxx] [libcxx] Undefine all supported C math functions (PR #94533)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Sep 23 11:36:42 PDT 2024


================
@@ -307,53 +307,79 @@ long double    truncl(long double x);
 // back to C++ linkage before including these C++ headers.
 extern "C++" {
 
-#    ifdef fpclassify
-#      undef fpclassify
-#    endif
-
-#    ifdef signbit
-#      undef signbit
-#    endif
-
-#    ifdef isfinite
-#      undef isfinite
-#    endif
-
-#    ifdef isinf
-#      undef isinf
-#    endif
-
-#    ifdef isnan
-#      undef isnan
-#    endif
-
-#    ifdef isnormal
-#      undef isnormal
-#    endif
-
-#    ifdef isgreater
-#      undef isgreater
-#    endif
-
-#    ifdef isgreaterequal
-#      undef isgreaterequal
-#    endif
-
-#    ifdef isless
-#      undef isless
-#    endif
-
-#    ifdef islessequal
-#      undef islessequal
-#    endif
-
-#    ifdef islessgreater
-#      undef islessgreater
-#    endif
-
-#    ifdef isunordered
-#      undef isunordered
-#    endif
+// According to section 7.1.4 Use of library functions of the C standard, any
----------------
ldionne wrote:

I read that comment, but I still don't understand what's happening that would prevent the `#undef` from being located right before the definition of the libc++ function with the same name. It seems like we need exactly one canonical place where we `#undef foo` and then define `namespace std { int foo(); }`, and I don't see how this can lead to problems?

https://github.com/llvm/llvm-project/pull/94533


More information about the libcxx-commits mailing list