From 78ecdf4c6ece4d8ce1de7d71409f6bcaedbb3136 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Tue, 25 Feb 2014 15:50:06 +0000 Subject: [PATCH] fixed: win32 warnings. --- CMakeLists.txt | 60 +++++++++++----------------- src/lib/client/CClient.cpp | 2 +- src/lib/io/CCryptoMode.h | 6 +++ src/lib/io/CCryptoStream.h | 5 +++ src/lib/server/CServer.cpp | 2 +- src/test/integtests/NetworkTests.cpp | 2 +- 6 files changed, 37 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a3da4c9..c9e5ed21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,10 +46,10 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) # for unix, put debug files in a separate bin "debug" dir. # release bin files should stay in the root of the bin dir. if (CMAKE_GENERATOR STREQUAL "Unix Makefiles") - if (CMAKE_BUILD_TYPE STREQUAL Debug) - set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/debug) - set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/debug) - endif() + if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/debug) + set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/debug) + endif() endif() # Set some easy to type variables. @@ -69,8 +69,7 @@ if (UNIX) # warnings as errors: # we have a problem with people checking in code with warnings. - set(CMAKE_CXX_FLAGS "-Werror") - + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") # For config.h, detect the libraries, functions, etc. include(CheckIncludeFiles) @@ -253,12 +252,12 @@ if (UNIX) if (HAVE_Xrandr) list(APPEND libs Xrandr) endif() - - # this was outside of the linux scope, - # not sure why, moving it back inside. - if(HAVE_Xi) - list(APPEND libs Xi) - endif() + + # this was outside of the linux scope, + # not sure why, moving it back inside. + if(HAVE_Xi) + list(APPEND libs Xi) + endif() endif() @@ -313,39 +312,26 @@ add_subdirectory(src) add_subdirectory(tools) if (WIN32) - # add /analyze in order to unconver potential bugs in the source code - # Details: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx - # add /FR to generate browse information (ncb files) usefull for using IDE + # TODO: consider using /analyze to uncover potential bugs in the source code. - #define _BIND_TO_CURRENT_CRT_VERSION 1 - #define _BIND_TO_CURRENT_ATL_VERSION 1 - #define _BIND_TO_CURRENT_MFC_VERSION 1 - #define _BIND_TO_CURRENT_OPENMP_VERSION 1 - # next line replaced the previous 4 ones: - #define _BIND_TO_CURRENT_VCLIBS_VERSION 1; - - # compiler: /MP - use multi cores to compile - # added _SECURE_SCL=1 for finding bugs with iterators - http://msdn.microsoft.com/en-us/library/aa985965.aspx + # /WX - warnings as errors (we have a problem with people checking in code with warnings). + # /FR - generate browse information (ncb files) useful for using IDE. + # /MP - use multi cores to compile. + # /D _BIND_TO_CURRENT_VCLIBS_VERSION - TODO: explain why. + # /D _SECURE_SCL=1 - find bugs with iterators. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /FR /MP /D _BIND_TO_CURRENT_VCLIBS_VERSION=1 /D _SECURE_SCL=1") - # common args between all vs builds - set(VS_ARGS "/FR /MP /D _BIND_TO_CURRENT_VCLIBS_VERSION=1 /D _SECURE_SCL=1 ${VS_ARGS_EXTRA}") - - # we may use `cmake -D VS_ARGS_EXTRA="/analyze"` for example to specify - # analyze mode (since we don't always want to use it; e.g. on non-team - # or non-x86 compiler editions where there's no support) - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${VS_ARGS}") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${VS_ARGS}") - - # this line removes "/D NDEBUG" from release, we want them in order to - # find bugs even on release builds. - set(CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2") + # /MD - use multi-core libraries. + # /O2 - get the fastest code. + # /Ob2 - expand inline functions (auto-inlining). + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2 /Ob2") endif() if (CONF_CPACK) if (WIN32) - message(FATAL_ERROR "CPack support for Windows has been removed.") + message(FATAL_ERROR "CPack support for Windows has been removed.") endif() if (UNIX) diff --git a/src/lib/client/CClient.cpp b/src/lib/client/CClient.cpp index 193bffc9..72fcb5da 100644 --- a/src/lib/client/CClient.cpp +++ b/src/lib/client/CClient.cpp @@ -800,7 +800,7 @@ CClient::dragInfoReceived(UInt32 fileNum, CString data) CDragInformation::parseDragInfo(m_dragFileList, fileNum, data); LOG((CLOG_DEBUG "drag info received, total drag file number: %i", m_dragFileList.size())); - for (int i = 0; i < m_dragFileList.size(); ++i) { + for (size_t i = 0; i < m_dragFileList.size(); ++i) { LOG((CLOG_DEBUG2 "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str())); } diff --git a/src/lib/io/CCryptoMode.h b/src/lib/io/CCryptoMode.h index 5c2f8cc3..29ecaf70 100644 --- a/src/lib/io/CCryptoMode.h +++ b/src/lib/io/CCryptoMode.h @@ -20,14 +20,20 @@ #include "ECryptoMode.h" #include "CString.h" +#if SYSAPI_UNIX #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wtautological-compare" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-function" +#endif + #include #include #include + +#if SYSAPI_UNIX #pragma GCC diagnostic pop +#endif //! Encapsulation of modes /*! diff --git a/src/lib/io/CCryptoStream.h b/src/lib/io/CCryptoStream.h index c771d0c0..0515117b 100644 --- a/src/lib/io/CCryptoStream.h +++ b/src/lib/io/CCryptoStream.h @@ -21,12 +21,17 @@ #include "CStreamFilter.h" #include "CCryptoMode.h" +#if SYSAPI_UNIX #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wall" +#endif + #include #include +#if SYSAPI_UNIX #pragma GCC diagnostic pop +#endif class CCryptoOptions; diff --git a/src/lib/server/CServer.cpp b/src/lib/server/CServer.cpp index 07c04729..42d34f23 100644 --- a/src/lib/server/CServer.cpp +++ b/src/lib/server/CServer.cpp @@ -2350,7 +2350,7 @@ CServer::dragInfoReceived(UInt32 fileNum, CString content) CDragInformation::parseDragInfo(m_dragFileList, fileNum, content); LOG((CLOG_DEBUG "drag info received, total drag file number: %i", m_dragFileList.size())); - for (int i = 0; i < m_dragFileList.size(); ++i) { + for (size_t i = 0; i < m_dragFileList.size(); ++i) { LOG((CLOG_DEBUG "dragging file %i name: %s", i + 1, m_dragFileList.at(i).c_str())); } diff --git a/src/test/integtests/NetworkTests.cpp b/src/test/integtests/NetworkTests.cpp index b06ce135..9bc52d2a 100644 --- a/src/test/integtests/NetworkTests.cpp +++ b/src/test/integtests/NetworkTests.cpp @@ -472,7 +472,7 @@ newMockData(size_t size) data += headSize; size_t times = (size - headSize - tailSize) / synergyRocksSize; - for (SInt32 i = 0; i < times; ++i) { + for (size_t i = 0; i < times; ++i) { memcpy(data, synergyRocks, synergyRocksSize); data += synergyRocksSize; }