Procházet zdrojové kódy

Fixed warnings with -pedantic

Christophe Riccio před 11 roky
rodič
revize
abb5299e08
3 změnil soubory, kde provedl 25 přidání a 21 odebrání
  1. 10 8
      CMakeLists.txt
  2. 3 1
      glm/detail/type_vec4.hpp
  3. 12 12
      test/gtc/gtc_bitfield.cpp

+ 10 - 8
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()
 

+ 3 - 1
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)

+ 12 - 12
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<unsigned int>(TimeMix));
+		printf("mask[loop]: %d\n", static_cast<unsigned int>(TimeLoop));
+		printf("mask[default]: %d\n", static_cast<unsigned int>(TimeDefault));
+		printf("mask[zero]: %d\n", static_cast<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(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<unsigned int>(Time));
 		}
 #		endif//(GLM_ARCH != GLM_ARCH_PURE)