Skip to content

fix: Define M_PI, M_PI_2, and M_1_PI.#393

Merged
spe-ciellt merged 1 commit intogerbv:developfrom
eyal0:m_pi
Mar 8, 2026
Merged

fix: Define M_PI, M_PI_2, and M_1_PI.#393
spe-ciellt merged 1 commit intogerbv:developfrom
eyal0:m_pi

Conversation

@eyal0
Copy link
Copy Markdown
Collaborator

@eyal0 eyal0 commented Mar 7, 2026

They are non-standard and not necessarily defined already.

This fixes #392.

They are non-standard and not necessarily defined already.

This fixes gerbv#392.
Copy link
Copy Markdown
Contributor

@rampageservices rampageservices left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Values match glibc and MSVC's _USE_MATH_DEFINES definitions exactly:

Constant PR value MSVC/glibc
M_PI 3.14159265358979323846 3.14159265358979323846
M_PI_2 1.57079632679489661923 1.57079632679489661923
M_1_PI 0.31830988618379067154 0.318309886183790671538

M_1_PI differs only in trailing precision (20 vs 21 digits) — both well beyond double range (~15–16 significant digits), so no practical difference.

#ifndef guards are the standard pattern. Placement in gerbv.h ensures coverage for the DEG2RAD/RAD2DEG macros defined just below, plus all transitive includers.

@spe-ciellt
Copy link
Copy Markdown
Contributor

Looks simple enough, I merge it.

@spe-ciellt spe-ciellt merged commit 1e8b25a into gerbv:develop Mar 8, 2026
7 checks passed
rampageservices added a commit to SourceParts/gerbv that referenced this pull request Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

M_PI is undefined.

3 participants