diff --git a/CMakeLists.txt b/CMakeLists.txt index f5c87550..f0f99dc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(CMakePackageConfigHelpers) enable_testing() -add_definitions(-D_CRT_SECURE_NO_WARNINGS) +add_definitions(-D_CRT_SECURE_NO_WARNINGS -g -Weverything -Wpedantic -Werror -Wno-padded -Wno-c++98-compat -Wno-documentation -std=c++11) option(GLM_STATIC_LIBRARY_ENABLE "GLM static library" OFF) if(GLM_STATIC_LIBRARY_ENABLE) diff --git a/glm/detail/func_common.inl b/glm/detail/func_common.inl index a78e3d38..67fda483 100644 --- a/glm/detail/func_common.inl +++ b/glm/detail/func_common.inl @@ -696,7 +696,15 @@ namespace detail GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v) { - return reinterpret_cast(const_cast(v)); + union + { + float in; + int out; + } u; + + u.in = v; + + return u.out; } template class vecType, length_t L, precision P> @@ -707,7 +715,15 @@ namespace detail GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v) { - return reinterpret_cast(const_cast(v)); + union + { + float in; + uint out; + } u; + + u.in = v; + + return u.out; } template class vecType, length_t L, precision P> @@ -718,7 +734,15 @@ namespace detail GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v) { - return reinterpret_cast(const_cast(v)); + union + { + int in; + float out; + } u; + + u.in = v; + + return u.out; } template class vecType, length_t L, precision P> @@ -729,7 +753,15 @@ namespace detail GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v) { - return reinterpret_cast(const_cast(v)); + union + { + uint in; + float out; + } u; + + u.in = v; + + return u.out; } template class vecType, length_t L, precision P> diff --git a/glm/detail/func_common_simd.inl b/glm/detail/func_common_simd.inl index e6daa269..2b6ac5fa 100644 --- a/glm/detail/func_common_simd.inl +++ b/glm/detail/func_common_simd.inl @@ -191,7 +191,7 @@ namespace detail { GLM_FUNC_QUALIFIER static vec<4, float, P> call(vec<4, float, P> const & x, vec<4, float, P> const & y, vec<4, bool, P> const & a) { - __m128i const Load = _mm_set_epi32(-(int)a.w, -(int)a.z, -(int)a.y, -(int)a.x); + __m128i const Load = _mm_set_epi32(-static_cast(a.w), -static_cast(a.z), -static_cast(a.y), -static_cast(a.x)); __m128 const Mask = _mm_castsi128_ps(Load); vec<4, float, P> Result(uninitialize); diff --git a/glm/detail/func_integer.inl b/glm/detail/func_integer.inl index d4b184c8..8c3b1dd0 100644 --- a/glm/detail/func_integer.inl +++ b/glm/detail/func_integer.inl @@ -298,12 +298,12 @@ namespace detail GLM_FUNC_QUALIFIER vecType bitfieldReverse(vecType const& v) { vecType x(v); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, T(0x5555555555555555ull), static_cast( 1)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, T(0x3333333333333333ull), static_cast( 2)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, T(0x00FF00FF00FF00FFull), static_cast( 8)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, T(0x0000FFFF0000FFFFull), static_cast(16)); - x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, T(0x00000000FFFFFFFFull), static_cast(32)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 2>::call(x, static_cast(0x5555555555555555ull), static_cast( 1)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 4>::call(x, static_cast(0x3333333333333333ull), static_cast( 2)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 8>::call(x, static_cast(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 16>::call(x, static_cast(0x00FF00FF00FF00FFull), static_cast( 8)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 32>::call(x, static_cast(0x0000FFFF0000FFFFull), static_cast(16)); + x = detail::compute_bitfieldReverseStep::value, sizeof(T) * 8>= 64>::call(x, static_cast(0x00000000FFFFFFFFull), static_cast(32)); return x; } diff --git a/glm/detail/func_integer_simd.inl b/glm/detail/func_integer_simd.inl index ddff75ba..095adfb9 100644 --- a/glm/detail/func_integer_simd.inl +++ b/glm/detail/func_integer_simd.inl @@ -11,11 +11,11 @@ namespace detail template struct compute_bitfieldReverseStep<4, uint32, P, vec, true, true> { - GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & v, uint32 Mask, uint32 Shift) + GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const& v, uint32 Mask, uint32 Shift) { __m128i const set0 = v.data; - __m128i const set1 = _mm_set1_epi32(Mask); + __m128i const set1 = _mm_set1_epi32(static_cast(Mask)); __m128i const and1 = _mm_and_si128(set0, set1); __m128i const sft1 = _mm_slli_epi32(and1, Shift); @@ -32,11 +32,11 @@ namespace detail template struct compute_bitfieldBitCountStep<4, uint32, P, vec, true, true> { - GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const & v, uint32 Mask, uint32 Shift) + GLM_FUNC_QUALIFIER static vec<4, uint32, P> call(vec<4, uint32, P> const& v, uint32 Mask, uint32 Shift) { __m128i const set0 = v.data; - __m128i const set1 = _mm_set1_epi32(Mask); + __m128i const set1 = _mm_set1_epi32(static_cast(Mask)); __m128i const and0 = _mm_and_si128(set0, set1); __m128i const sft0 = _mm_slli_epi32(set0, Shift); __m128i const and1 = _mm_and_si128(sft0, set1); diff --git a/glm/detail/func_matrix_simd.inl b/glm/detail/func_matrix_simd.inl index 99491866..bf5e5ee8 100644 --- a/glm/detail/func_matrix_simd.inl +++ b/glm/detail/func_matrix_simd.inl @@ -19,9 +19,9 @@ namespace detail { mat<4, 4, float, P> result(uninitialize); glm_mat4_matrixCompMult( - *(glm_vec4 const (*)[4])&x[0].data, - *(glm_vec4 const (*)[4])&y[0].data, - *(glm_vec4(*)[4])&result[0].data); + *static_cast(&x[0].data), + *static_cast(&y[0].data), + *static_cast(&result[0].data)); return result; } }; @@ -33,8 +33,8 @@ namespace detail { mat<4, 4, float, P> result(uninitialize); glm_mat4_transpose( - *(glm_vec4 const (*)[4])&m[0].data, - *(glm_vec4(*)[4])&result[0].data); + *static_cast(&m[0].data), + *static_cast(&result[0].data)); return result; } }; diff --git a/glm/detail/type_half.inl b/glm/detail/type_half.inl index 78d3e261..fa049f7e 100644 --- a/glm/detail/type_half.inl +++ b/glm/detail/type_half.inl @@ -46,7 +46,7 @@ namespace detail // detail::uif32 result; - result.i = (unsigned int)(s << 31); + result.i = static_cast(s << 31); return result.f; } else @@ -74,7 +74,7 @@ namespace detail // uif32 result; - result.i = (unsigned int)((s << 31) | 0x7f800000); + result.i = static_cast((s << 31) | 0x7f800000); return result.f; } else @@ -84,7 +84,7 @@ namespace detail // uif32 result; - result.i = (unsigned int)((s << 31) | 0x7f800000 | (m << 13)); + result.i = static_cast((s << 31) | 0x7f800000 | (m << 13)); return result.f; } } @@ -101,15 +101,15 @@ namespace detail // uif32 Result; - Result.i = (unsigned int)((s << 31) | (e << 23) | m); + Result.i = static_cast((s << 31) | (e << 23) | m); return Result.f; } - GLM_FUNC_QUALIFIER hdata toFloat16(float const & f) + GLM_FUNC_QUALIFIER hdata toFloat16(float const& f) { uif32 Entry; Entry.f = f; - int i = (int)Entry.i; + int i = static_cast(Entry.i); // // Our floating point number, f, is represented by the bit diff --git a/readme.md b/readme.md index f5181bc6..e2d75ca3 100644 --- a/readme.md +++ b/readme.md @@ -73,7 +73,8 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Added FAQ 12: Windows headers cause build errors... #557 - Removed GCC shadow warnings #595 - Added error for including of different versions of GLM #619 -- Added GLM_FORCE_IGNORE_VERSION to ignore error caused by including different version of GLM #619 +- Added GLM_FORCE_IGNORE_VERSION to ignore error caused by including different version of GLM #619 +- Reduced warnings when using very strict compilation flags #646 #### Fixes: - Removed doxygen references to GTC_half_float which was removed in 0.9.4