From 2cc0c53da75daeaf4dbbd9a8dabbd23343c6a98b Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Tue, 8 Aug 2017 23:19:16 +0200 Subject: [PATCH] Fixed warnings --- CMakeLists.txt | 4 ++-- glm/gtc/quaternion.inl | 5 +++-- glm/gtx/common.inl | 4 +++- glm/gtx/log_base.inl | 2 +- glm/gtx/scalar_relational.inl | 4 ++-- test/core/core_func_common.cpp | 16 ++++++++-------- test/gtc/gtc_packing.cpp | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f385a13b..560a5522 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,8 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_definitions(-Weverything -Wpedantic -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-documentation -Wno-gnu-anonymous-struct -Wno-nested-anon-types) - add_definitions(-Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare) + add_definitions(-Weverything -Wpedantic -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++11-long-long -Wno-padded -Wno-documentation -Wno-gnu-anonymous-struct -Wno-nested-anon-types) + add_definitions(-Wno-sign-conversion -Wno-unused-variable -Wno-missing-prototypes -Wno-unreachable-code -Wno-missing-variable-declarations -Wno-sign-compare -Wno-global-constructors) endif() option(GLM_TEST_ENABLE_LANG_EXTENSIONS "Enable language extensions" OFF) diff --git a/glm/gtc/quaternion.inl b/glm/gtc/quaternion.inl index b0fc1ea9..9f2fdae4 100644 --- a/glm/gtc/quaternion.inl +++ b/glm/gtc/quaternion.inl @@ -5,6 +5,7 @@ #include "../geometric.hpp" #include "../exponential.hpp" #include "../detail/compute_vector_relational.hpp" +#include "epsilon.hpp" #include namespace glm{ @@ -352,13 +353,13 @@ namespace detail template GLM_FUNC_QUALIFIER bool operator==(tquat const & q1, tquat const & q2) { - return (q1.x == q2.x) && (q1.y == q2.y) && (q1.z == q2.z) && (q1.w == q2.w); + return all(epsilonEqual(q1, q2, epsilon())); } template GLM_FUNC_QUALIFIER bool operator!=(tquat const & q1, tquat const & q2) { - return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w); + return any(epsilonNotEqual(q1, q2, epsilon())); } // -- Operations -- diff --git a/glm/gtx/common.inl b/glm/gtx/common.inl index 97b5c7d3..5e78905b 100644 --- a/glm/gtx/common.inl +++ b/glm/gtx/common.inl @@ -2,6 +2,8 @@ /// @file glm/gtx/common.inl #include +#include "../gtc/epsilon.hpp" +#include "../gtc/constants.hpp" namespace glm{ namespace detail @@ -33,7 +35,7 @@ namespace detail # if GLM_HAS_CXX11_STL return std::fpclassify(x) == FP_SUBNORMAL; # else - return x != static_cast(0) && std::fabs(x) < std::numeric_limits::min(); + return epsilonNotEqual(x, static_cast(0), epsilon()) && std::fabs(x) < std::numeric_limits::min(); # endif } diff --git a/glm/gtx/log_base.inl b/glm/gtx/log_base.inl index 9155778a..fc31e781 100644 --- a/glm/gtx/log_base.inl +++ b/glm/gtx/log_base.inl @@ -6,7 +6,7 @@ namespace glm template GLM_FUNC_QUALIFIER genType log(genType const & x, genType const & base) { - assert(x != genType(0)); + assert(!detail::compute_equal::call(x, static_cast(0))); return glm::log(x) / glm::log(base); } diff --git a/glm/gtx/scalar_relational.inl b/glm/gtx/scalar_relational.inl index ba9ec9d8..e044efb4 100644 --- a/glm/gtx/scalar_relational.inl +++ b/glm/gtx/scalar_relational.inl @@ -50,7 +50,7 @@ namespace glm T const & y ) { - return x == y; + return detail::compute_equal::call(x, y); } template @@ -60,7 +60,7 @@ namespace glm T const & y ) { - return x != y; + return !detail::compute_equal::call(x, y); } GLM_FUNC_QUALIFIER bool any diff --git a/test/core/core_func_common.cpp b/test/core/core_func_common.cpp index 4ddd7b35..16388318 100644 --- a/test/core/core_func_common.cpp +++ b/test/core/core_func_common.cpp @@ -332,7 +332,7 @@ namespace mix_ T Result; }; - entry TestBool[] = + entry const TestBool[] = { {0.0f, 1.0f, false, 0.0f}, {0.0f, 1.0f, true, 1.0f}, @@ -340,7 +340,7 @@ namespace mix_ {-1.0f, 1.0f, true, 1.0f} }; - entry TestFloat[] = + entry const TestFloat[] = { {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 1.0f, 1.0f}, @@ -348,7 +348,7 @@ namespace mix_ {-1.0f, 1.0f, 1.0f, 1.0f} }; - entry TestVec2Bool[] = + entry const TestVec2Bool[] = { {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}, @@ -356,7 +356,7 @@ namespace mix_ {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)} }; - entry TestBVec2[] = + entry const TestBVec2[] = { {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)}, {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}, @@ -365,7 +365,7 @@ namespace mix_ {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)} }; - entry TestVec3Bool[] = + entry const TestVec3Bool[] = { {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}, @@ -373,7 +373,7 @@ namespace mix_ {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)} }; - entry TestBVec3[] = + entry const TestBVec3[] = { {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)}, {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}, @@ -382,7 +382,7 @@ namespace mix_ {glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)} }; - entry TestVec4Bool[] = + entry const TestVec4Bool[] = { {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}, @@ -390,7 +390,7 @@ namespace mix_ {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)} }; - entry TestBVec4[] = + entry const TestBVec4[] = { {glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), glm::vec4(2.0f, 2.0f, 3.0f, 3.0f), glm::bvec4(false, true, false, true), glm::vec4(0.0f, 2.0f, 1.0f, 3.0f)}, {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}, diff --git a/test/gtc/gtc_packing.cpp b/test/gtc/gtc_packing.cpp index a5593fd5..5f9cb2a3 100644 --- a/test/gtc/gtc_packing.cpp +++ b/test/gtc/gtc_packing.cpp @@ -153,7 +153,7 @@ int test_U3x10_1x2() } glm::u8vec4 const v0(0xff, 0x77, 0x0, 0x33); - glm::uint32 const p0 = *(glm::uint32*)(&v0[0]); + glm::uint32 const p0 = *reinterpret_cast(&v0[0]); glm::uint32 const r0 = 0x330077ff; Error += p0 == r0 ? 0 : 1;