Re: [Kicad-developers] MacOS build issue with new geometry tests

2018-07-30 Thread Maciej Sumiński
Hi John,

Thanks for the patch. I have had the same problem compiling KiCad with
clang and I confirm that the proposed fix solves the problem, so I
merged it.

Cheers,
Orson

On 07/29/2018 05:34 PM, John Beard wrote:
> Hi Adam,
> 
> Sorry, this in my stuff - I though that was a way to get PI without
> having to guess the setting of _USE_MATH_DEFINES or do #ifdefs like at
> the top of dl_codes.h, but obviously not.
> 
> The attached patch might work, but I can't test on a Mac, so all I can
> say is "it builds for me and the tests pass". Specifically,
> _USE_MATH_DEFINES may need to be set for qa_geometry if not already.
> 
> Cheers,
> 
> John
> 
> 
> On Sun, Jul 29, 2018 at 1:38 PM, Adam Wolf
>  wrote:
>> Hi folks!
>>
>> There's a build failure on the new geometry test stuff with MacOS.
>>
>> qa/geometry/geom_test_utils.h:33:18: error: constexpr variable 'PI'
>> must be initialized by a constant expression
>> constexpr double PI = atan(1.0) * 4.0;
>> ^ ~~~
>> qa/geometry/geom_test_utils.h:33:23: note: non-constexpr function
>> 'atan' cannot be used in a constant expression
>> constexpr double PI = atan(1.0) * 4.0;
>>
>> There are a few others, all which look about the same.  I am on my way
>> out of town today so I don't have time to look for a solution, but a
>> user actually reported it to me due to using the new MacOS build
>> scripts! :D
>>
>> Adam Wolf
>>
>> ___
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to : kicad-developers@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>> ___
>> Mailing list: https://launchpad.net/~kicad-developers
>> Post to : kicad-developers@lists.launchpad.net
>> Unsubscribe : https://launchpad.net/~kicad-developers
>> More help   : https://help.launchpad.net/ListHelp




signature.asc
Description: OpenPGP digital signature
___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Kicad-developers] MacOS build issue with new geometry tests

2018-07-29 Thread Bernhard Stegmaier
Hi,

it’s not constexpr that breaks clang.
Usage of floating point isn’t valid in a constexpr (only literals allowed, 
floating point isn’t a literal)…
  https://en.cppreference.com/w/cpp/language/constexpr 



Regards,
Bernhard

> On 29. Jul 2018, at 17:34, John Beard  wrote:
> 
> ___

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


Re: [Kicad-developers] MacOS build issue with new geometry tests

2018-07-29 Thread John Beard
Hi Adam,

Sorry, this in my stuff - I though that was a way to get PI without
having to guess the setting of _USE_MATH_DEFINES or do #ifdefs like at
the top of dl_codes.h, but obviously not.

The attached patch might work, but I can't test on a Mac, so all I can
say is "it builds for me and the tests pass". Specifically,
_USE_MATH_DEFINES may need to be set for qa_geometry if not already.

Cheers,

John


On Sun, Jul 29, 2018 at 1:38 PM, Adam Wolf
 wrote:
> Hi folks!
>
> There's a build failure on the new geometry test stuff with MacOS.
>
> qa/geometry/geom_test_utils.h:33:18: error: constexpr variable 'PI'
> must be initialized by a constant expression
> constexpr double PI = atan(1.0) * 4.0;
> ^ ~~~
> qa/geometry/geom_test_utils.h:33:23: note: non-constexpr function
> 'atan' cannot be used in a constant expression
> constexpr double PI = atan(1.0) * 4.0;
>
> There are a few others, all which look about the same.  I am on my way
> out of town today so I don't have time to look for a solution, but a
> user actually reported it to me due to using the new MacOS build
> scripts! :D
>
> Adam Wolf
>
> ___
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@lists.launchpad.net
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
From 28d23f2c73a7f824ddb3474e46ea79071fe075a9 Mon Sep 17 00:00:00 2001
From: John Beard 
Date: Sun, 29 Jul 2018 16:29:02 +0100
Subject: [PATCH] Use M_PI for Pi, not constexpr calculation

Constexpr evaluation breaks Clang compilation.

Use math.h M_PI, as elsewhere.
---
 qa/geometry/geom_test_utils.h | 11 +--
 qa/geometry/test_fillet.cpp   |  3 ++-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/qa/geometry/geom_test_utils.h b/qa/geometry/geom_test_utils.h
index cb4e9721f..d598a24df 100644
--- a/qa/geometry/geom_test_utils.h
+++ b/qa/geometry/geom_test_utils.h
@@ -24,15 +24,14 @@
 #ifndef GEOM_TEST_UTILS_H
 #define GEOM_TEST_UTILS_H
 
+#include 
+
 /**
  * @brief Utility functions for testing geometry functions.
  */
 namespace GEOM_TEST
 {
 
-constexpr double PI = atan(1.0) * 4.0;
-constexpr double PI_2 = atan(1.0) * 2.0;
-
 /**
  * @brief Check if a value is within a tolerance of a nominal value
  *
@@ -159,12 +158,12 @@ bool ArePerpendicular( const VECTOR2& a, const VECTOR2& b, double aToleran
 auto angle = std::abs( a.Angle() - b.Angle() );
 
 // Normalise: angles of 3*pi/2 are also perpendicular
-if (angle > PI)
+if (angle > M_PI)
 {
-angle -= PI;
+angle -= M_PI;
 }
 
-return IsWithin( angle, PI_2, aTolerance );
+return IsWithin( angle, M_PI / 2.0, aTolerance );
 }
 
 /**
diff --git a/qa/geometry/test_fillet.cpp b/qa/geometry/test_fillet.cpp
index 10a7fe725..c7d758ec6 100644
--- a/qa/geometry/test_fillet.cpp
+++ b/qa/geometry/test_fillet.cpp
@@ -68,8 +68,9 @@ void TestFilletSegmentConstraints( const SEG& aSeg, VECTOR2I aRadCentre,
 ( diffC.EuclideanNorm() )( aRadius )( aError + 1 ) );
 
 // Check 3: Mid-point -> radius centre perpendicular
+const auto perpendularityMaxError = ( M_PI / 2 ) / 10;
 BOOST_CHECK_PREDICATE( ArePerpendicular,
-( diffC )( aSeg.A - aSeg.B )( PI_2 / 10 ) );
+( diffC )( aSeg.A - aSeg.B )( perpendularityMaxError ) );
 }
 
 
-- 
2.17.1

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp


[Kicad-developers] MacOS build issue with new geometry tests

2018-07-29 Thread Adam Wolf
Hi folks!

There's a build failure on the new geometry test stuff with MacOS.

qa/geometry/geom_test_utils.h:33:18: error: constexpr variable 'PI'
must be initialized by a constant expression
constexpr double PI = atan(1.0) * 4.0;
^ ~~~
qa/geometry/geom_test_utils.h:33:23: note: non-constexpr function
'atan' cannot be used in a constant expression
constexpr double PI = atan(1.0) * 4.0;

There are a few others, all which look about the same.  I am on my way
out of town today so I don't have time to look for a solution, but a
user actually reported it to me due to using the new MacOS build
scripts! :D

Adam Wolf

___
Mailing list: https://launchpad.net/~kicad-developers
Post to : kicad-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kicad-developers
More help   : https://help.launchpad.net/ListHelp