From 0e995b514097dae6df5109f708fe3db8d6476239 Mon Sep 17 00:00:00 2001 From: David Williams Date: Sat, 21 Mar 2015 07:40:32 +0100 Subject: [PATCH] Fixed some compiler warnings. --- CMakeLists.txt | 4 ++++ examples/OpenGL/Shapes.cpp | 4 ++-- tests/TestVolumeSubclass.cpp | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 785531d0..0b4738bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") #Maybe "OR ADD_DEFINITIONS(-std=c++0x) #Enable C++0x mode ENDIF() +IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) +ENDIF() + ADD_SUBDIRECTORY(include) OPTION(ENABLE_EXAMPLES "Should the examples be built" ON) diff --git a/examples/OpenGL/Shapes.cpp b/examples/OpenGL/Shapes.cpp index 8821e7fb..77628f22 100644 --- a/examples/OpenGL/Shapes.cpp +++ b/examples/OpenGL/Shapes.cpp @@ -57,8 +57,8 @@ void createSphereInVolume(RawVolume& volData, float fRadi void createCubeInVolume(RawVolume& volData, Vector3DInt32 lowerCorner, Vector3DInt32 upperCorner, uint8_t uValue) { - uint8_t maxDen = MaterialDensityPair88::getMaxDensity(); - uint8_t minDen = MaterialDensityPair88::getMinDensity(); + uint8_t maxDen = static_cast(MaterialDensityPair88::getMaxDensity()); + uint8_t minDen = static_cast(MaterialDensityPair88::getMinDensity()); //This three-level for loop iterates over every voxel between the specified corners for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++) { diff --git a/tests/TestVolumeSubclass.cpp b/tests/TestVolumeSubclass.cpp index eb5238ca..0cccb3a2 100644 --- a/tests/TestVolumeSubclass.cpp +++ b/tests/TestVolumeSubclass.cpp @@ -73,7 +73,9 @@ public: /// Gets a voxel at the position given by x,y,z coordinates VoxelType getVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos) const { - if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2))) + if ((uXPos >= 0) && (uXPos < static_cast(mVolumeData.getDimension(0))) && + (uYPos >= 0) && (uYPos < static_cast(mVolumeData.getDimension(1))) && + (uZPos >= 0) && (uZPos < static_cast(mVolumeData.getDimension(2)))) { return mVolumeData(uXPos, uYPos, uZPos); } @@ -94,7 +96,9 @@ public: /// Sets the voxel at the position given by x,y,z coordinates bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) { - if ((uXPos < mVolumeData.getDimension(0)) && (uYPos < mVolumeData.getDimension(1)) && (uZPos < mVolumeData.getDimension(2))) + if( (uXPos >= 0) && (uXPos < static_cast(mVolumeData.getDimension(0))) && + (uYPos >= 0) && (uYPos < static_cast(mVolumeData.getDimension(1))) && + (uZPos >= 0) && (uZPos < static_cast(mVolumeData.getDimension(2)))) { mVolumeData(uXPos, uYPos, uZPos) = tValue; return true;