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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libspeexdsp/testresample2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
POSSIBILITY OF SUCH DAMAGE.
*/

#define _USE_MATH_DEFINES
#include <math.h>

#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


#define PERIOD 32
Expand Down