Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a fallback for M_PI and M_PI_2 #412

Merged
merged 4 commits into from
Oct 26, 2023
Merged

Conversation

dl1jbe
Copy link
Member

@dl1jbe dl1jbe commented Oct 19, 2023

As C standards does not define M_PI or M_PI_2 provide a fallback. Some LIBC implementations (e.g. MUSL) miss these definitions.

@zcsahok
Copy link
Member

zcsahok commented Oct 22, 2023

Could we just define one of these? For example drop M_PI as M_PI_2 is used in more places and define RADIAN in terms of M_PI_2? Ideally even M_PI shall come from a single (.h) file.

@dl1jbe
Copy link
Member Author

dl1jbe commented Oct 23, 2023

Makes sense. I would also move the definition of RADIANS there.
I see two ways:

a) prepare a tlf_math.h (which includes math.h and defines M_PI_2 if needed) and include it everywhere instead of math.h.

b) define it in sunup.h as that is already needed by muf.c (but has to be added to sunup.c yet).

@zcsahok
Copy link
Member

zcsahok commented Oct 26, 2023

Fine with me, thanks.

@dl1jbe
Copy link
Member Author

dl1jbe commented Oct 26, 2023

Thanks for the feedback.

@dl1jbe dl1jbe merged commit 563f35b into Tlf:master Oct 26, 2023
2 checks passed
@dl1jbe dl1jbe deleted the PI_fallback branch October 26, 2023 18:09
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.

None yet

2 participants