Just #define _GNU_SOURCE and _USE_MATH_MACROS unconditionally#1419
Just #define _GNU_SOURCE and _USE_MATH_MACROS unconditionally#1419sethk wants to merge 1 commit intoNetflix:masterfrom
Conversation
Remove definitions of M_PI from source.
- _USE_MATH_MACROS is required by MSVC when compiling against UCRT.
- _GNU_SOURCE is required for other functions that are extensions to
The macros in math.h are not part of POSIX, but are visible by default
so long as you don't declare you are trying to be strictly
POSIX-conformant by defining _POSIX_C_SOURCE or _XOPEN_SOURCE.
Tested on:
- macOS 11.7.9 (it's old, sorry)
Apple clang version 13.0.0,
x86_64-apple-darwin20.6.0
- FreeBSD 14.2-RELEASE
FreeBSD clang version 18.1.6
x86_64-unknown-freebsd14.2
- Amazon Linux release 2 (Karoo) 4.14.336-253.554.amzn2.x86_64
cc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-17)
x86_64-redhat-linux
- Windows 11 24H2:
- MSYS2 c++ (GCC) 13.3.0
x86_64-pc-msys
msys-2.0.dll runtime
- CLANG64 clang version 19.1.4
x86_64-w64-windows-gnu
ucrtbase.dll runtime
- MINGW64 cc.exe (Rev2, Built by MSYS2 project) 14.2.0
x86_64-w64-mingw32
msvcrt.dll runtime
- UCRT64 cc.exe (Rev2, Built by MSYS2 project) 14.2.0
x86_64-w64-mingw32
ucrtbase.dll runtime
- Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34433 for x64
(Requires a few additional PRs that I will submit)
|
@alyssais and @kylophone , can you please review? I tried to simplify the defines here to also support MSVC on Windows, FreeBSD, and everything else imaginable without having to redefine M_PI in multiple places. |
|
Are |
|
Per @alyssais ' last change to |
Remove definitions of M_PI from source.
_USE_MATH_MACROSis required by MSVC when compiling against UCRT._GNU_SOURCEis required for other functions that are extensions toThe macros in math.h are not part of POSIX, but are visible by default so long as you don't declare you are trying to be strictly POSIX-conformant by defining
_POSIX_C_SOURCEor_XOPEN_SOURCE.Tested on:
macOS 11.7.9 (it's old, sorry)
Apple clang version 13.0.0
x86_64-apple-darwin20.6.0
FreeBSD 14.2-RELEASE
FreeBSD clang version 18.1.6
x86_64-unknown-freebsd14.2
Amazon Linux release 2 (Karoo) 4.14.336-253.554.amzn2.x86_64
cc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-17)
x86_64-redhat-linux
Windows 11 24H2:
MSYS2 c++ (GCC) 13.3.0
x86_64-pc-msys
msys-2.0.dll runtime
CLANG64 clang version 19.1.4
x86_64-w64-windows-gnu
ucrtbase.dll runtime
MINGW64 cc.exe (Rev2, Built by MSYS2 project)
14.2.0 x86_64-w64-mingw32
msvcrt.dll runtime
UCRT64 cc.exe (Rev2, Built by MSYS2 project)
14.2.0 x86_64-w64-mingw32
ucrtbase.dll runtime
Microsoft (R) C/C++ Optimizing Compiler Version 19.42.34433 for x64
(Requires a few additional PRs that I will submit)