From d12c0e1206a885211050e3a9d481fa3583568067 Mon Sep 17 00:00:00 2001 From: Chris Mumford Date: Tue, 19 Nov 2024 11:13:55 -0500 Subject: [PATCH 1/2] Use M_PI instead of M_PIl M_PIl is the double precision constant for pi (3.14...). This is not defined in all toolchains, resulting in the following build error: ``` test/testcpp.cc:46:35: error: use of undeclared identifier 'M_PIl'; did you mean 'P_PID'? 46 | long double phinc = 2*k0* M_PIl / nfft; | ^~~~~ | P_PID ``` The double precision constants may be a GNU extension. See: https://www.gnu.org/software/libc/manual/html_node/Mathematical-Constants.html_node Switching the test to use the single precision M_PI avoids this error. The test still passes as the added precision of the double is not required. This fixes #87. --- test/testcpp.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testcpp.cc b/test/testcpp.cc index a62f6e0..11ab291 100644 --- a/test/testcpp.cc +++ b/test/testcpp.cc @@ -43,7 +43,7 @@ void dotest(int nfft) long double difpower=0; for (int k0=0;k0 acc = 0; - long double phinc = 2*k0* M_PIl / nfft; + long double phinc = 2*k0* M_PI / nfft; for (int k1=0;k1 x(inbuf[k1].real(),inbuf[k1].imag()); acc += x * exp( complex(0,-k1*phinc) ); From aff158e92202bd068240954469cba21de4bc4ffc Mon Sep 17 00:00:00 2001 From: Chris Mumford Date: Fri, 11 Jul 2025 13:59:41 -0400 Subject: [PATCH 2/2] Create long double pi constant --- test/testcpp.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/testcpp.cc b/test/testcpp.cc index 11ab291..b9dee94 100644 --- a/test/testcpp.cc +++ b/test/testcpp.cc @@ -7,6 +7,7 @@ */ #include "kissfft.hh" #include +#include #include #include @@ -41,9 +42,14 @@ void dotest(int nfft) long double totalpower=0; long double difpower=0; + + // Create long double constant for pi because M_PIl is not defined by + // all toolchains. + const long double pi = std::acosl(-1); + for (int k0=0;k0 acc = 0; - long double phinc = 2*k0* M_PI / nfft; + long double phinc = 2*k0* pi / nfft; for (int k1=0;k1 x(inbuf[k1].real(),inbuf[k1].imag()); acc += x * exp( complex(0,-k1*phinc) );