From abb5299e08c25fa9bfb225e0599add513b2fe16d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Wed, 29 Oct 2014 10:28:25 +0100 Subject: [PATCH] Fixed warnings with -pedantic --- CMakeLists.txt | 18 ++++++++++-------- glm/detail/type_vec4.hpp | 4 +++- test/gtc/gtc_bitfield.cpp | 24 ++++++++++++------------ 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 685710f5..cb03700f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,6 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" option(GLM_TEST_ENABLE_CXX_0X "Enable C++ 0x" OFF) option(GLM_TEST_ENABLE_CXX_11 "Enable C++ 11" OFF) option(GLM_TEST_ENABLE_CXX_1Y "Enable C++ 1y" OFF) - option(GLM_TEST_ENABLE_CXX_PEDANTIC "Pedantic" ON) - - if(GLM_TEST_ENABLE_CXX_PEDANTIC) - add_definitions(-pedantic) - endif() if(GLM_TEST_ENABLE_CXX_1Y) set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++1y") @@ -44,11 +39,18 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" endif() endif() -if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32)) - option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF) +option(GLM_TEST_ENABLE_MS_EXTENSIONS "Enable MS extensions" OFF) - if(NOT GLM_TEST_ENABLE_MS_EXTENSIONS) +if(GLM_TEST_ENABLE_MS_EXTENSIONS) + if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")) + add_definitions(-Wgnu-anonymous-struct) + add_definitions(-Wnested-anon-types) + endif() +elseif() + if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") OR (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") AND WIN32)) add_definitions(/Za) + elseif(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")) + add_definitions(-pedantic) endif() endif() diff --git a/glm/detail/type_vec4.hpp b/glm/detail/type_vec4.hpp index 87edf3d2..f92b6a38 100644 --- a/glm/detail/type_vec4.hpp +++ b/glm/detail/type_vec4.hpp @@ -112,6 +112,7 @@ namespace detail # endif//GLM_SWIZZLE }; # else +/* # if GLM_HAS_UNRESTRICTED_UNIONS union { @@ -125,11 +126,12 @@ namespace detail }; }; # else +*/ union { T x, r, s; }; union { T y, g, t; }; union { T z, b, p; }; union { T w, a, q; }; -# endif +//s# endif # ifdef GLM_SWIZZLE GLM_SWIZZLE_GEN_VEC_FROM_VEC4(T, P, tvec4, tvec2, tvec3, tvec4) diff --git a/test/gtc/gtc_bitfield.cpp b/test/gtc/gtc_bitfield.cpp index ea4eef00..2504d1c2 100644 --- a/test/gtc/gtc_bitfield.cpp +++ b/test/gtc/gtc_bitfield.cpp @@ -89,10 +89,10 @@ namespace mask std::clock_t TimeDefault = Timestamp4 - Timestamp3; std::clock_t TimeZero = Timestamp5 - Timestamp4; - printf("mask[mix]: %d\n", TimeMix); - printf("mask[loop]: %d\n", TimeLoop); - printf("mask[default]: %d\n", TimeDefault); - printf("mask[zero]: %d\n", TimeZero); + printf("mask[mix]: %d\n", static_cast(TimeMix)); + printf("mask[loop]: %d\n", static_cast(TimeLoop)); + printf("mask[default]: %d\n", static_cast(TimeDefault)); + printf("mask[zero]: %d\n", static_cast(TimeZero)); return TimeDefault < TimeLoop ? 0 : 1; } @@ -497,7 +497,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("glm::bitfieldInterleave Time %d clocks\n", Time); + std::printf("glm::bitfieldInterleave Time %d clocks\n", static_cast(Time)); } { @@ -508,7 +508,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("fastBitfieldInterleave Time %d clocks\n", Time); + std::printf("fastBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { @@ -519,7 +519,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("loopBitfieldInterleave Time %d clocks\n", Time); + std::printf("loopBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { @@ -530,7 +530,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("interleaveBitfieldInterleave Time %d clocks\n", Time); + std::printf("interleaveBitfieldInterleave Time %d clocks\n", static_cast(Time)); } # if(GLM_ARCH != GLM_ARCH_PURE) @@ -542,7 +542,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("sseBitfieldInterleave Time %d clocks\n", Time); + std::printf("sseBitfieldInterleave Time %d clocks\n", static_cast(Time)); } { @@ -553,7 +553,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("sseUnalignedBitfieldInterleave Time %d clocks\n", Time); + std::printf("sseUnalignedBitfieldInterleave Time %d clocks\n", static_cast(Time)); } # endif//(GLM_ARCH != GLM_ARCH_PURE) @@ -565,7 +565,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", Time); + std::printf("glm::detail::bitfieldInterleave Time %d clocks\n", static_cast(Time)); } # if(GLM_ARCH != GLM_ARCH_PURE) @@ -583,7 +583,7 @@ namespace bitfieldInterleave std::clock_t Time = std::clock() - LastTime; - std::printf("_mm_bit_interleave_si128 Time %d clocks\n", Time); + std::printf("_mm_bit_interleave_si128 Time %d clocks\n", static_cast(Time)); } # endif//(GLM_ARCH != GLM_ARCH_PURE)