Just #define _GNU_SOURCE and _USE_MATH_MACROS unconditionally #1419
+2
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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_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)