diff --git a/.gitignore b/.gitignore index 4d2cd84a85..4c81ab67b7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ tmp # Ignore build trees. /build* +/out # CLion integrated development environment /cmake-build-* # Ignore install dir. @@ -28,3 +29,5 @@ dependencies/* # MAC File System files .DS_Store +/CMakeSettings.json + diff --git a/Applications/opensense/opensense.cpp b/Applications/opensense/opensense.cpp index 15f6a40e3f..0f2fb833ff 100644 --- a/Applications/opensense/opensense.cpp +++ b/Applications/opensense/opensense.cpp @@ -453,7 +453,7 @@ void addImuFramesFromMarkers(const string& modelFile, const string& markersFile) // store joint initial pose from marker IK as default pose for the model. model.setPropertiesFromState(s); - for (int i = 0; i < offsets.size(); ++i) { + for (int i = 0; i < (int)offsets.size(); ++i) { // add imu offset frames to the model with model taking ownership bodies[i]->addComponent(offsets[i]); } diff --git a/CMakeLists.txt b/CMakeLists.txt index e889020c87..a4c5ebbf59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -359,8 +359,6 @@ if(WIN32 AND ${CMAKE_C_COMPILER} MATCHES "cl") set(mxcpu ${BUILD_LIMIT_PARALLEL_COMPILES}) # abbreviation ## C++ - # Disable "C4068: unknown pragma" warning. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4068") set(CMAKE_CXX_FLAGS_DEBUG "/MP${mxcpu} /D _DEBUG /MDd /Od /Ob0 /RTC1 /Zi /bigobj /GS- ${CL_INST_SET}" CACHE STRING "VC++ Debug build compile flags" FORCE) @@ -388,6 +386,13 @@ if(WIN32 AND ${CMAKE_C_COMPILER} MATCHES "cl") "/MP${mxcpu} /D NDEBUG /MD /O1 /Ob1 /Oi /GS- ${CL_INST_SET}" CACHE STRING "VC++ MinSizeRel build compile flags" FORCE) + # Treat warnings as errors. + # Ideally we would increase the warning level to 4 but that generates + # warnings in our dependencies. + # Convert warning 4388 ('operator' signed/unsigned mismatch) from + # level 4 to level 3 for consistency with Clang. + add_compile_options(/WX /w34388) # /W4 + endif() set(BUILD_JAVA_WRAPPING OFF CACHE BOOL "Build Java wrapping (needed if you're building the GUI or the Matlab wrapping; requires that you have SWIG and Java installed on your machine.)") diff --git a/OpenSim/Auxiliary/auxiliaryTestFunctions.h b/OpenSim/Auxiliary/auxiliaryTestFunctions.h index 2fe01fa163..df97fdda6c 100644 --- a/OpenSim/Auxiliary/auxiliaryTestFunctions.h +++ b/OpenSim/Auxiliary/auxiliaryTestFunctions.h @@ -133,7 +133,7 @@ void ASSERT_EQUAL( const Container& vecA, throw OpenSim::Exception(message, file, line); } else { - for (auto i = 0; i < vecA.size(); ++i) { + for (int i = 0; i < (int)vecA.size(); ++i) { // if both values are NaN treat them as being equivalent if ( SimTK::isNaN(vecA[i]) && SimTK::isNaN(vecB[i]) ) continue; diff --git a/OpenSim/Common/APDMDataReader.cpp b/OpenSim/Common/APDMDataReader.cpp index 933478b3d4..6cfeb0681a 100644 --- a/OpenSim/Common/APDMDataReader.cpp +++ b/OpenSim/Common/APDMDataReader.cpp @@ -226,7 +226,7 @@ void APDMDataReader::find_start_column(std::vector tokens, found_index = static_cast(std::distance(tokens.begin(), it)); // now check the following indices for match with remaining search_labels bool match = true; - for (int remaining = 1; remaining < search_labels.size() && match; remaining++) { + for (int remaining = 1; remaining < (int)search_labels.size() && match; remaining++) { match = tokens[found_index + remaining]. compare(sensorName + search_labels[remaining]) == 0; } diff --git a/OpenSim/Common/ComponentSocket.cpp b/OpenSim/Common/ComponentSocket.cpp index 2415af7bc5..7feb0767b2 100644 --- a/OpenSim/Common/ComponentSocket.cpp +++ b/OpenSim/Common/ComponentSocket.cpp @@ -45,7 +45,7 @@ void AbstractSocket::prependComponentPathToConnecteePath( ComponentPath path(getConnecteePath(iConn)); if (path.isAbsolute()) { ComponentPath newPath(pathToPrepend); - for (int iPath = 0; iPath < path.getNumPathLevels(); + for (int iPath = 0; iPath < (int)path.getNumPathLevels(); ++iPath) { newPath.pushBack( path.getSubcomponentNameAtLevel(iPath)); @@ -71,7 +71,7 @@ void AbstractInput::prependComponentPathToConnecteePath( ComponentPath path(componentPath); if (path.isAbsolute()) { ComponentPath newPath(pathToPrepend); - for (int iPath = 0; iPath < path.getNumPathLevels(); + for (int iPath = 0; iPath < (int)path.getNumPathLevels(); ++iPath) { newPath.pushBack( path.getSubcomponentNameAtLevel(iPath)); diff --git a/OpenSim/Common/DataTable.h b/OpenSim/Common/DataTable.h index 6ee78c3385..27985b9a3d 100644 --- a/OpenSim/Common/DataTable.h +++ b/OpenSim/Common/DataTable.h @@ -938,7 +938,7 @@ class DataTable_ : public AbstractDataTable { InvalidArgument, "Column-label '" + columnLabel + "' already exists in " "the DataTable."); - OPENSIM_THROW_IF(depCol.nrow() != getNumRows(), + OPENSIM_THROW_IF(depCol.nrow() != (int)getNumRows(), IncorrectNumRows, static_cast(getNumRows()), static_cast(depCol.nrow())); @@ -1223,10 +1223,10 @@ class DataTable_ : public AbstractDataTable { DataTable_(const std::vector& indVec, const SimTK::Matrix_& depData, const std::vector& labels) { - OPENSIM_THROW_IF(indVec.size() != depData.nrow(), InvalidArgument, + OPENSIM_THROW_IF((int)indVec.size() != depData.nrow(), InvalidArgument, "Length of independent column does not match number of rows of " "dependent data."); - OPENSIM_THROW_IF(labels.size() != depData.ncol(), InvalidArgument, + OPENSIM_THROW_IF((int)labels.size() != depData.ncol(), InvalidArgument, "Number of labels does not match number of columns of " "dependent data."); diff --git a/OpenSim/Common/DelimFileAdapter.h b/OpenSim/Common/DelimFileAdapter.h index 21f4814514..adaa500042 100644 --- a/OpenSim/Common/DelimFileAdapter.h +++ b/OpenSim/Common/DelimFileAdapter.h @@ -433,7 +433,7 @@ DelimFileAdapter::extendRead(const std::string& fileName) const { auto row_vector = readElems(row); - OPENSIM_THROW_IF(row_vector.size() != column_labels.size(), + OPENSIM_THROW_IF(row_vector.size() != (int)column_labels.size(), RowLengthMismatch, fileName, line_num, diff --git a/OpenSim/Common/Test/testAPDMDataReader.cpp b/OpenSim/Common/Test/testAPDMDataReader.cpp index 3aa79102be..caa2270423 100644 --- a/OpenSim/Common/Test/testAPDMDataReader.cpp +++ b/OpenSim/Common/Test/testAPDMDataReader.cpp @@ -36,7 +36,7 @@ int main() { std::vector imu_names{ "torso", "pelvis", "shank" }; std::vector names_in_experiment{ "Static", "Upper", "Middle" }; // Programmatically add items to name mapping, write to xml - for (int index = 0; index < imu_names.size(); ++index) { + for (int index = 0; index < (int)imu_names.size(); ++index) { ExperimentalSensor nextSensor(names_in_experiment[index], imu_names[index]); readerSettings.append_ExperimentalSensors(nextSensor); } @@ -113,7 +113,7 @@ void testAPDMFormat7() { std::vector imu_names{ "imu1", "imu2", "imu4" }; std::vector names_in_experiment{ "Lumbar", "Right Ankle", "Right Foot" }; // Programmatically add items to name mapping, write to xml - for (int index = 0; index < imu_names.size(); ++index) { + for (int index = 0; index < (int)imu_names.size(); ++index) { ExperimentalSensor nextSensor(names_in_experiment[index], imu_names[index]); readerSettings.append_ExperimentalSensors(nextSensor); } diff --git a/OpenSim/Common/Test/testXsensDataReader.cpp b/OpenSim/Common/Test/testXsensDataReader.cpp index 80b682e7a9..dc020672d7 100644 --- a/OpenSim/Common/Test/testXsensDataReader.cpp +++ b/OpenSim/Common/Test/testXsensDataReader.cpp @@ -42,7 +42,7 @@ int main() { std::vector imu_names{ "shank", "thigh" }; std::vector file_names{ "000_00B421AF", "000_00B4227B" }; // Programmatically add items to Map, write to xml - for (int index = 0; index < imu_names.size(); ++index) { + for (int index = 0; index < (int)imu_names.size(); ++index) { ExperimentalSensor nextSensor(file_names[index], imu_names[index]); readerSettings.append_ExperimentalSensors(nextSensor); } diff --git a/OpenSim/Simulation/Model/ExternalLoads.cpp b/OpenSim/Simulation/Model/ExternalLoads.cpp index 457d65d41e..59e29512ed 100644 --- a/OpenSim/Simulation/Model/ExternalLoads.cpp +++ b/OpenSim/Simulation/Model/ExternalLoads.cpp @@ -251,7 +251,7 @@ void ExternalLoads::transformPointsExpressedInGroundToAppliedBodies( } // Once we've transformed the forces (done with computation), // then replace them in the Set - for (int i = 0; i < transformedForces.size(); ++i) { + for (int i = 0; i < (int)transformedForces.size(); ++i) { ExternalForce *transformedExf = transformedForces[i]; if (transformedExf) { set(i, transformedExf); diff --git a/OpenSim/Simulation/OpenSense/InverseKinematicsStudy.cpp b/OpenSim/Simulation/OpenSense/InverseKinematicsStudy.cpp index 72d611f272..ff57259cd8 100644 --- a/OpenSim/Simulation/OpenSense/InverseKinematicsStudy.cpp +++ b/OpenSim/Simulation/OpenSense/InverseKinematicsStudy.cpp @@ -96,7 +96,7 @@ void InverseKinematicsStudy:: std::cout << "press any key to visualize experimental marker data ..." << std::endl; std::cin >> c; - for (size_t j =startEnd[0]; j <= startEnd[1]; j=j+10) { + for (int j =startEnd[0]; j <= startEnd[1]; j=j+10) { std::cout << "time: " << times[j] << "s" << std::endl; state.setTime(times[j]); previewWorld.realizePosition(state); diff --git a/OpenSim/Simulation/OpenSense/OpenSenseUtilities.cpp b/OpenSim/Simulation/OpenSense/OpenSenseUtilities.cpp index 571a29d971..eb113c3291 100644 --- a/OpenSim/Simulation/OpenSense/OpenSenseUtilities.cpp +++ b/OpenSim/Simulation/OpenSense/OpenSenseUtilities.cpp @@ -52,7 +52,7 @@ TimeSeriesTable_ OpenSenseUtilities:: SimTK::Matrix_ matrix(int(nt), nc, Rotation()); int cnt = 0; - for (size_t i = startEnd[0]; i <= startEnd[1]; ++i) { + for (int i = startEnd[0]; i <= startEnd[1]; ++i) { newTimes[cnt] = times[i]; const auto& quatRow = quaternionsTable.getRowAtIndex(i); for (int j = 0; j < nc; ++j) { diff --git a/OpenSim/Simulation/SimulationUtilities.cpp b/OpenSim/Simulation/SimulationUtilities.cpp index d127c619c9..3283ab24f0 100644 --- a/OpenSim/Simulation/SimulationUtilities.cpp +++ b/OpenSim/Simulation/SimulationUtilities.cpp @@ -181,7 +181,7 @@ void OpenSim::updateSocketConnecteesBySearch(Model& model) int numSocketsUpdated = 0; for (auto& comp : model.updComponentList()) { const auto socketNames = comp.getSocketNames(); - for (int i = 0; i < socketNames.size(); ++i) { + for (int i = 0; i < (int)socketNames.size(); ++i) { auto& socket = comp.updSocket(socketNames[i]); try { socket.finalizeConnection(model); diff --git a/appveyor.yml b/appveyor.yml index 9066bb6e77..8ea886d136 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -102,12 +102,11 @@ build_script: # for some reason. - cd %OPENSIM_BUILD_DIR% # Configure. # TODO -DBUILD_SIMM_TRANSLATOR=ON - # Set the CXXFLAGS environment variable to turn warnings into errors. # Skip timing test section included by default - - cmake -E env CXXFLAGS="/WX -DSKIP_TIMING" cmake %OPENSIM_SOURCE_DIR% -G"%CMAKE_GENERATOR%" -T"%CMAKE_TOOLSET%" -DSIMBODY_HOME=C:\simbody%NUGET_PACKAGE_ID_SUFFIX% -DOPENSIM_DEPENDENCIES_DIR=%OPENSIM_DEPENDENCIES_INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%OPENSIM_INSTALL_DIR% -DBUILD_JAVA_WRAPPING=ON -DBUILD_PYTHON_WRAPPING=ON -DWITH_BTK:BOOL=ON + - cmake -E env CXXFLAGS="-DSKIP_TIMING" cmake %OPENSIM_SOURCE_DIR% -G"%CMAKE_GENERATOR%" -T"%CMAKE_TOOLSET%" -DSIMBODY_HOME=C:\simbody%NUGET_PACKAGE_ID_SUFFIX% -DOPENSIM_DEPENDENCIES_DIR=%OPENSIM_DEPENDENCIES_INSTALL_DIR% -DCMAKE_INSTALL_PREFIX=%OPENSIM_INSTALL_DIR% -DBUILD_JAVA_WRAPPING=ON -DBUILD_PYTHON_WRAPPING=ON -DWITH_BTK:BOOL=ON # Build. - - cmake --build . --config Release -- /maxcpucount:4 /verbosity:quiet #/p:TreatWarningsAsErrors="true" + - cmake --build . --config Release -- /maxcpucount:4 /verbosity:quiet test_script: ## Run tests.