Fix C++ warnings with XCode 7 compiler

Clang included with XCode 7 has a new warning that isn't handled in Boost yet.
Also fixed error using `abs` improperly with int64_t in Bond tests.
This commit is contained in:
Adam Sapek 2015-10-16 12:11:59 -07:00 коммит произвёл Adam Sapek
Родитель 28c75802f3
Коммит 8d64c0e4e8
3 изменённых файлов: 19 добавлений и 8 удалений

Просмотреть файл

@ -44,8 +44,19 @@ message(STATUS "Boost Python Library: ${Boost_PYTHON_LIBRARY}")
# disable Boost auto-linking
add_definitions (-DBOOST_ALL_NO_LIB)
cxx_add_compile_options(Clang -fPIC -Wall -Werror)
cxx_add_compile_options(GNU -fPIC -Wall -Werror)
cxx_add_compile_options(Clang
-fPIC
-Wall
-Werror
-Wno-unknown-warning-option
-Wno-unused-local-typedefs)
cxx_add_compile_options(GNU
-fPIC
-Wall
-Werror
-Wno-unknown-warning-option
-Wno-unused-local-typedefs)
include_directories (
${BOND_INCLUDE}

Просмотреть файл

@ -6,15 +6,15 @@ class Compare;
inline bool Equal(double left, double right)
{
// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
int64_t l = *(int*)&left;
int64_t l = *(int64_t*)&left;
if (l < 0)
l = 0x8000000000000000LL - l;
int64_t r = *(int*)&right;
int64_t r = *(int64_t*)&right;
if (r < 0)
r = 0x8000000000000000LL - r;
return abs(l - r) < 5;
return (l - r) < 5 && (l - r) > -5;
}

Просмотреть файл

@ -42,15 +42,15 @@ private:
inline bool Equal(double left, double right)
{
// http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
int64_t l = *(int*)&left;
int64_t l = *(int64_t*)&left;
if (l < 0)
l = 0x8000000000000000LL - l;
int64_t r = *(int*)&right;
int64_t r = *(int64_t*)&right;
if (r < 0)
r = 0x8000000000000000LL - r;
return abs(l - r) < 5;
return (l - r) < 5 && (l - r) > -5;
}