Author: pcc Date: Thu Jan 25 17:19:23 2018 New Revision: 323490 URL: http://llvm.org/viewvc/llvm-project?rev=323490&view=rev Log: libcxx: Move #include_next <math.h> out of header guard in wrapper header.
Code on Windows expects to be able to do: #define _USE_MATH_DEFINES #include <math.h> and receive the definitions of mathematical constants, even if <math.h> has previously been included. To support this scenario, re-include <math.h> every time the wrapper header is included. Differential Revision: https://reviews.llvm.org/D42403 Added: libcxx/trunk/test/libcxx/depr/depr.c.headers/math_h.sh.cpp Modified: libcxx/trunk/include/math.h Modified: libcxx/trunk/include/math.h URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=323490&r1=323489&r2=323490&view=diff ============================================================================== --- libcxx/trunk/include/math.h (original) +++ libcxx/trunk/include/math.h Thu Jan 25 17:19:23 2018 @@ -8,6 +8,16 @@ // //===----------------------------------------------------------------------===// +// This include lives outside the header guard in order to support an MSVC +// extension which allows users to do: +// +// #define _USE_MATH_DEFINES +// #include <math.h> +// +// and receive the definitions of mathematical constants, even if <math.h> +// has previously been included. +#include_next <math.h> + #ifndef _LIBCPP_MATH_H #define _LIBCPP_MATH_H @@ -298,8 +308,6 @@ long double truncl(long double x); #pragma GCC system_header #endif -#include_next <math.h> - #ifdef __cplusplus // We support including .h headers inside 'extern "C"' contexts, so switch Added: libcxx/trunk/test/libcxx/depr/depr.c.headers/math_h.sh.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/depr/depr.c.headers/math_h.sh.cpp?rev=323490&view=auto ============================================================================== --- libcxx/trunk/test/libcxx/depr/depr.c.headers/math_h.sh.cpp (added) +++ libcxx/trunk/test/libcxx/depr/depr.c.headers/math_h.sh.cpp Thu Jan 25 17:19:23 2018 @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// RUN: %compile -fsyntax-only + +#ifdef _MSC_VER + +#include <math.h> + +#define _USE_MATH_DEFINES +#include <math.h> + +#ifndef M_PI +#error M_PI not defined +#endif + +#endif _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits