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

Resolve build error C2065: 'M_PI': undeclared identifier` (fix issue #49) #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dutchman101
Copy link

Refer to issue #49

This is subject to maintainer choosing another way
cc @tmatth

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "speex/speex_resampler.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
Copy link
Member

@tmatth tmatth Oct 4, 2024

Choose a reason for hiding this comment

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

The current convention (for broadest portability) used in xiph projects is to define M_PI as needed, e.g.

diff --git a/libspeexdsp/testresample2.c b/libspeexdsp/testresample2.c
index 99a830d..5f5b938 100644
--- a/libspeexdsp/testresample2.c
+++ b/libspeexdsp/testresample2.c
@@ -39,6 +39,10 @@
 #include <math.h>
 #include <stdlib.h>
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 #define PERIOD 32
 #define INBLOCK 1024
 #define RATE 48000

See e.g.,

#ifndef M_PI

Copy link
Member

@tmatth tmatth left a comment

Choose a reason for hiding this comment

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

See inline comments.

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.

2 participants