Skip to content

Commit

Permalink
Reduced warnings when using very strict compilation flags #646
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovounet committed Jul 7, 2017
1 parent 27f8e5b commit 1ad55c5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

This comment has been minimized.

Copy link
@SeriousAlexej

SeriousAlexej Jul 23, 2017

-Weverything flag breaks compilation on gcc 4.8.4 with "g++: error: unrecognized command line option ‘-Weverything’"


option(GLM_STATIC_LIBRARY_ENABLE "GLM static library" OFF)
if(GLM_STATIC_LIBRARY_ENABLE)
Expand Down
40 changes: 36 additions & 4 deletions glm/detail/func_common.inl
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,15 @@ namespace detail

GLM_FUNC_QUALIFIER int floatBitsToInt(float const & v)
{
return reinterpret_cast<int&>(const_cast<float&>(v));
union
{
float in;
int out;
} u;

u.in = v;

return u.out;
}

template<template<length_t, typename, precision> class vecType, length_t L, precision P>
Expand All @@ -707,7 +715,15 @@ namespace detail

GLM_FUNC_QUALIFIER uint floatBitsToUint(float const & v)
{
return reinterpret_cast<uint&>(const_cast<float&>(v));
union
{
float in;
uint out;
} u;

u.in = v;

return u.out;
}

template<template<length_t, typename, precision> class vecType, length_t L, precision P>
Expand All @@ -718,7 +734,15 @@ namespace detail

GLM_FUNC_QUALIFIER float intBitsToFloat(int const & v)
{
return reinterpret_cast<float&>(const_cast<int&>(v));
union
{
int in;
float out;
} u;

u.in = v;

return u.out;
}

template<template<length_t, typename, precision> class vecType, length_t L, precision P>
Expand All @@ -729,7 +753,15 @@ namespace detail

GLM_FUNC_QUALIFIER float uintBitsToFloat(uint const & v)
{
return reinterpret_cast<float&>(const_cast<uint&>(v));
union
{
uint in;
float out;
} u;

u.in = v;

return u.out;
}

template<template<length_t, typename, precision> class vecType, length_t L, precision P>
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/func_common_simd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(a.w), -static_cast<int>(a.z), -static_cast<int>(a.y), -static_cast<int>(a.x));
__m128 const Mask = _mm_castsi128_ps(Load);

vec<4, float, P> Result(uninitialize);
Expand Down
12 changes: 6 additions & 6 deletions glm/detail/func_integer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,12 @@ namespace detail
GLM_FUNC_QUALIFIER vecType<L, T, P> bitfieldReverse(vecType<L, T, P> const& v)
{
vecType<L, T, P> x(v);
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, T(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, T(0x3333333333333333ull), static_cast<T>( 2));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, T(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, T(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, T(0x00000000FFFFFFFFull), static_cast<T>(32));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 2>::call(x, static_cast<T>(0x5555555555555555ull), static_cast<T>( 1));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 4>::call(x, static_cast<T>(0x3333333333333333ull), static_cast<T>( 2));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 8>::call(x, static_cast<T>(0x0F0F0F0F0F0F0F0Full), static_cast<T>( 4));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 16>::call(x, static_cast<T>(0x00FF00FF00FF00FFull), static_cast<T>( 8));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 32>::call(x, static_cast<T>(0x0000FFFF0000FFFFull), static_cast<T>(16));
x = detail::compute_bitfieldReverseStep<L, T, P, vecType, detail::is_aligned<P>::value, sizeof(T) * 8>= 64>::call(x, static_cast<T>(0x00000000FFFFFFFFull), static_cast<T>(32));
return x;
}

Expand Down
8 changes: 4 additions & 4 deletions glm/detail/func_integer_simd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ namespace detail
template<glm::precision P>
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<int>(Mask));
__m128i const and1 = _mm_and_si128(set0, set1);
__m128i const sft1 = _mm_slli_epi32(and1, Shift);

Expand All @@ -32,11 +32,11 @@ namespace detail
template<glm::precision P>
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<int>(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);
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/func_matrix_simd.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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<glm_vec4 const (*)[4]>(&x[0].data),
*static_cast<glm_vec4 const (*)[4]>(&y[0].data),
*static_cast<glm_vec4(*)[4]>(&result[0].data));
return result;
}
};
Expand All @@ -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<glm_vec4 const (*)[4]>(&m[0].data),
*static_cast<glm_vec4(*)[4]>(&result[0].data));
return result;
}
};
Expand Down
12 changes: 6 additions & 6 deletions glm/detail/type_half.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace detail
//

detail::uif32 result;
result.i = (unsigned int)(s << 31);
result.i = static_cast<unsigned int>(s << 31);
return result.f;
}
else
Expand Down Expand Up @@ -74,7 +74,7 @@ namespace detail
//

uif32 result;
result.i = (unsigned int)((s << 31) | 0x7f800000);
result.i = static_cast<unsigned int>((s << 31) | 0x7f800000);
return result.f;
}
else
Expand All @@ -84,7 +84,7 @@ namespace detail
//

uif32 result;
result.i = (unsigned int)((s << 31) | 0x7f800000 | (m << 13));
result.i = static_cast<unsigned int>((s << 31) | 0x7f800000 | (m << 13));
return result.f;
}
}
Expand All @@ -101,15 +101,15 @@ namespace detail
//

uif32 Result;
Result.i = (unsigned int)((s << 31) | (e << 23) | m);
Result.i = static_cast<unsigned int>((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<int>(Entry.i);

//
// Our floating point number, f, is represented by the bit
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ad55c5

Please sign in to comment.