← Back to team overview

kicad-developers team mailing list archive

Re: Interesting compiler warning

 

Le 26/06/2015 15:19, Chris Pavlina a écrit :
> Hi,
> 
> clang gives this warning a couple times:
> 
> [ 45%] Building CXX object polygon/CMakeFiles/polygon.dir/math_for_graphics.cpp.o
> /home/cmp/git/kicad/polygon/math_for_graphics.cpp:71:39: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
>                     *dist = std::min( abs( a - xi ), abs( a - xf ) );
>                                       ^
> /home/cmp/git/kicad/polygon/math_for_graphics.cpp:71:39: note: use function 'std::abs' instead
>                     *dist = std::min( abs( a - xi ), abs( a - xf ) );
>                                       ^~~
>                                       std::abs
> 
> Can someone familiar with that section have a look and see if that is 
> indeed the desired behavior? I'm thinking this will cause some rounding 
> errors in potentionally subtle places.
> 
> --
> Chris


should be std::abs.

Generally speaking, only std::min, std::max std::abs should be used in
Kicad code.


-- 
Jean-Pierre CHARRAS


Follow ups

References