kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #19108
[PATCH 1/4] Avoid bringing own definition of M_PI (MSVC warning C4005)
---
pcbnew/exporters/export_idf.cpp | 2 +-
utils/idftools/idf_common.cpp | 4 ++--
utils/idftools/idf_common.h | 13 +------------
utils/idftools/idf_parser.cpp | 2 +-
4 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp
index c50f39f..591c732 100644
--- a/pcbnew/exporters/export_idf.cpp
+++ b/pcbnew/exporters/export_idf.cpp
@@ -331,7 +331,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule,
if( dlength < drill )
{
std::swap( drill, dlength );
- angle += M_PI2;
+ angle += M_PI_2;
}
// NOTE: KiCad measures a slot's length from end to end
diff --git a/utils/idftools/idf_common.cpp b/utils/idftools/idf_common.cpp
index 20a3e5f..95a0d5d 100644
--- a/utils/idftools/idf_common.cpp
+++ b/utils/idftools/idf_common.cpp
@@ -1137,9 +1137,9 @@ void IDF_SEGMENT::CalcCenterAndRadius( void )
double h = sqrt( dh2 );
if( angle > 0.0 )
- offAng += M_PI2;
+ offAng += M_PI_2;
else
- offAng -= M_PI2;
+ offAng -= M_PI_2;
if( ( angle > 180.0 ) || ( angle < -180.0 ) )
offAng += M_PI;
diff --git a/utils/idftools/idf_common.h b/utils/idftools/idf_common.h
index ac8a4db..398f8f8 100644
--- a/utils/idftools/idf_common.h
+++ b/utils/idftools/idf_common.h
@@ -32,18 +32,7 @@
#include <fstream>
#include <exception>
#include <string>
-
-#ifndef M_PI
-#define M_PI 3.1415926535897932384626433832795028841
-#endif
-
-#ifndef M_PI2
-#define M_PI2 ( M_PI / 2.0 )
-#endif
-
-#ifndef M_PI4
-#define M_PI4 ( M_PI / 4.0 )
-#endif
+#include <cmath>
// differences in angle smaller than MIN_ANG are considered equal
#define MIN_ANG (0.01)
diff --git a/utils/idftools/idf_parser.cpp b/utils/idftools/idf_parser.cpp
index 68a45d7..563c456 100644
--- a/utils/idftools/idf_parser.cpp
+++ b/utils/idftools/idf_parser.cpp
@@ -3522,7 +3522,7 @@ bool IDF3_BOARD::AddSlot( double aWidth, double aLength, double aOrientation, do
}
double a1 = aOrientation / 180.0 * M_PI;
- double a2 = a1 + M_PI2;
+ double a2 = a1 + M_PI_2;
double d1 = aLength / 2.0;
double d2 = aWidth / 2.0;
double sa1 = sin( a1 );
Follow ups
References