Skip to content

Commit cad1eab

Browse files
committed
[libc++] Only include math implementation headers from math.h.
`math.h` has logic for undefining macros that might be defined in the C Standard Library. We need to make sure we do that prelude before referring to any function names that might potentially be macros; otherwise, valid user code that includes a macro-prone `<math.h>` from the C Standard Library before including `<cmath>` (or a header that transitively includes `<cmath>`) ends up broken.
1 parent 3aecf41 commit cad1eab

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

libcxx/include/cmath

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
313313
*/
314314

315315
#include <__config>
316-
#include <__math/hypot.h>
317316
#include <__type_traits/enable_if.h>
318317
#include <__type_traits/is_arithmetic.h>
319318
#include <__type_traits/is_constant_evaluated.h>
@@ -324,7 +323,6 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
324323
#include <limits>
325324
#include <version>
326325

327-
#include <__math/special_functions.h>
328326
#include <math.h>
329327

330328
#ifndef _LIBCPP_MATH_H

libcxx/include/math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ extern "C++" {
372372
# include <__math/remainder.h>
373373
# include <__math/roots.h>
374374
# include <__math/rounding_functions.h>
375+
# include <__math/special_functions.h>
375376
# include <__math/traits.h>
376377
# include <__math/trigonometric_functions.h>
377378
# include <__type_traits/enable_if.h>

0 commit comments

Comments
 (0)