diff --git a/Applications/Analyze/test/testAnalyzeTool.cpp b/Applications/Analyze/test/testAnalyzeTool.cpp index bc10147c36..d928400dc3 100644 --- a/Applications/Analyze/test/testAnalyzeTool.cpp +++ b/Applications/Analyze/test/testAnalyzeTool.cpp @@ -208,11 +208,11 @@ void testTugOfWar(const string& dataFileName, const double& defaultAct) { // Verify that the current computed and AnalyzeTool reported force are // equivalent for the provided motion file cout << s.getTime() << " :: muscle-fiber-force: " << mf << - " Analyze reported force: " << forces[i] << endl; - ASSERT_EQUAL(mf, forces[i], equilTol, __FILE__, __LINE__, + " Analyze reported force: " << forces[int(i)] << endl; + ASSERT_EQUAL(mf, forces[int(i)], equilTol, __FILE__, __LINE__, "Total fiber force failed to match reported muscle force."); - double delta = (i > 0) ? abs(forces[i]-forces[i-1]) : 0; + double delta = (i > 0) ? abs(forces[int(i)]-forces[int(i-1)]) : 0; SimTK_ASSERT_ALWAYS(delta < maxDelta, "Force trajectory has unexplained discontinuity."); diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8461ea6d..1c95fdc914 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -801,7 +801,7 @@ set(OPENSIM_SYSTEM_INFO ${CMAKE_SYSTEM}) set(OPENSIM_OS_NAME ${CMAKE_SYSTEM_NAME}) if( WIN32 ) - if (${MSVC_VERSION} GREATER 1910) + if (NOT (MSVC_VERSION LESS 2000)) message(AUTHOR_WARNING "OpenSim::GetCompilerVersion() " "in OpenSim/version.h does not handle this newer version " "(v${MSVC_VERSION}) of Microsoft Visual C++. " diff --git a/OpenSim/Analyses/InverseDynamics.cpp b/OpenSim/Analyses/InverseDynamics.cpp index e997c0586e..3196826b2d 100644 --- a/OpenSim/Analyses/InverseDynamics.cpp +++ b/OpenSim/Analyses/InverseDynamics.cpp @@ -458,7 +458,7 @@ begin(SimTK::State& s ) for(size_t i=0u; i(i)); } } diff --git a/OpenSim/Analyses/StaticOptimizationTarget.cpp b/OpenSim/Analyses/StaticOptimizationTarget.cpp index b5618db1f3..293228d7e7 100644 --- a/OpenSim/Analyses/StaticOptimizationTarget.cpp +++ b/OpenSim/Analyses/StaticOptimizationTarget.cpp @@ -78,7 +78,7 @@ StaticOptimizationTarget(const SimTK::State& s, Model *aModel,int aNP,int aNC, b for (size_t i = 0u; i < coordinates.size(); ++i) { const Coordinate& coord = *coordinates[i]; if(!coord.isConstrained(s)) { - _accelerationIndices.append(i); + _accelerationIndices.append(static_cast(i)); } } } diff --git a/OpenSim/Common/Component.h b/OpenSim/Common/Component.h index 4fb2d2253e..6e552c72b8 100644 --- a/OpenSim/Common/Component.h +++ b/OpenSim/Common/Component.h @@ -1517,11 +1517,11 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Component, Object); // subcomponents and to find the longest concrete class name. const std::string concreteClassName = this->getConcreteClassName(); unsigned numSubcomponents = 0; - unsigned maxlen = concreteClassName.length(); + size_t maxlen = concreteClassName.length(); for (const C& thisComp : compList) { ++numSubcomponents; auto len = thisComp.getConcreteClassName().length(); - maxlen = std::max(maxlen, static_cast(len)); + maxlen = std::max(maxlen, len); } if (numSubcomponents == 0) { diff --git a/OpenSim/Common/ComponentSocket.h b/OpenSim/Common/ComponentSocket.h index 2b461878c0..96682e58aa 100644 --- a/OpenSim/Common/ComponentSocket.h +++ b/OpenSim/Common/ComponentSocket.h @@ -797,7 +797,7 @@ class Input : public AbstractInput { SimTK::Vector_. The elements are in the same order as the channels. */ SimTK::Vector_ getVector(const SimTK::State& state) const { - SimTK::Vector_ v(_connectees.size()); + SimTK::Vector_ v(static_cast(_connectees.size())); for (unsigned ichan = 0u; ichan < _connectees.size(); ++ichan) { v[ichan] = _connectees[ichan]->getValue(state); } diff --git a/OpenSim/Common/Test/testComponentInterface.cpp b/OpenSim/Common/Test/testComponentInterface.cpp index 5c4eb6e13d..b2cdc408bb 100644 --- a/OpenSim/Common/Test/testComponentInterface.cpp +++ b/OpenSim/Common/Test/testComponentInterface.cpp @@ -1995,6 +1995,8 @@ void testAliasesAndLabels() { SimTK_TEST(foo->getInput("listInput1").getLabel(1) == "thud"); } +#include + int main() { //Register new types for testing deserialization @@ -2022,5 +2024,7 @@ int main() { SimTK_SUBTEST(testListInputConnecteeSerialization); SimTK_SUBTEST(testSingleValueInputConnecteeSerialization); + std::cout << OpenSim::GetCompilerVersion() << std::endl; + SimTK_END_TEST(); } diff --git a/OpenSim/Examples/Plugins/AnalysisPluginExample/AnalysisPlugin_Template.cpp b/OpenSim/Examples/Plugins/AnalysisPluginExample/AnalysisPlugin_Template.cpp index 18ae8eb8f2..253af7dd41 100644 --- a/OpenSim/Examples/Plugins/AnalysisPluginExample/AnalysisPlugin_Template.cpp +++ b/OpenSim/Examples/Plugins/AnalysisPluginExample/AnalysisPlugin_Template.cpp @@ -219,7 +219,6 @@ int AnalysisPlugin_Template:: record(const SimTK::State& s) { // VARIABLES - double dirCos[3][3]; SimTK::Vec3 vec,angVec; double Mass = 0.0; diff --git a/OpenSim/Simulation/SimbodyEngine/SimbodyEngine.cpp b/OpenSim/Simulation/SimbodyEngine/SimbodyEngine.cpp index b7ec397423..75aad3abdb 100644 --- a/OpenSim/Simulation/SimbodyEngine/SimbodyEngine.cpp +++ b/OpenSim/Simulation/SimbodyEngine/SimbodyEngine.cpp @@ -1038,7 +1038,7 @@ void SimbodyEngine::scaleRotationalDofColumns(Storage &rStorage, double factor) void SimbodyEngine::scaleRotationalDofColumns(TimeSeriesTable& table, double factor) const { - int ncols = table.getNumColumns(); + size_t ncols = table.getNumColumns(); if(ncols == 0) throw Exception("SimbodyEngine.scaleRotationalDofColumns: ERROR- storage has no labels, can't determine coordinate types for deg<->rad conversion", __FILE__,__LINE__); @@ -1052,7 +1052,7 @@ void SimbodyEngine::scaleRotationalDofColumns(TimeSeriesTable& table, const CoordinateSet& coordinateSet = _model->getCoordinateSet(); // first column is time, so skip - for (int i = 0; i < ncols; i++) { + for (size_t i = 0; i < ncols; i++) { const std::string& name = table.getColumnLabel(i); index = coordinateSet.getIndex(name); if (index < 0){ diff --git a/OpenSim/version.h b/OpenSim/version.h index 1b3e2d1061..424312291a 100644 --- a/OpenSim/version.h +++ b/OpenSim/version.h @@ -68,37 +68,53 @@ namespace OpenSim { } inline std::string GetCompilerVersion() { std::string os = GetOSInfo(); - std::string str; + std::string str = "(Unknown)"; if( 0 == os.compare("Windows")) { - switch( atoi(GET_COMPILER_INFO) ) { - case 1910: - str = "Visual Studio 2017"; - break; - case 1900: - str = "Visual Studio 2015"; - break; - case 1800: - str = "Visual Studio 2013"; - break; - case 1700: - str = "Visual Studio 2011"; - break; - case 1600: - str = "Visual Studio 2010"; - break; - case 1500: - str = "Visual Studio 2008"; - break; - case 1400: - str = "Visual Studio 2005"; - break; - case 1310: - str = "Visual Studio 2003"; - break; - case 1300: - str = "Visual Studio 2002"; - break; + const int MSVCVersion = atoi(GET_COMPILER_INFO); + if( MSVCVersion >= 1910 ) { + // With Visual Studio 2017, the versioning of the Visual C++ + // compiler became more fine-grained, so we can no longer use + // a switch statement. + // Also, Visual Studio 2017 decouples the Visual Studio IDE + // from the C++ toolset (compiler), so providing the IDE year + // does not indicate the compiler version (it may be possible + // to use the Visual Studio 2019 IDE, or whatever is next, + // with the same C++ toolset that came with Visual Studio 2017. + // Therefore, we no longer provide the Visual Studio year. + // https://blogs.msdn.microsoft.com/vcblog/2016/10/05/visual-c-compiler-version/ + // https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B + if (1910 <= MSVCVersion && MSVCVersion < 2000) { + str = "Microsoft Visual C++ 14.1"; + } + str += " (MSC_VER " + std::to_string(MSVCVersion) + ")"; + } else { + switch( MSVCVersion ) { + case 1900: + str = "Visual Studio 2015"; + break; + case 1800: + str = "Visual Studio 2013"; + break; + case 1700: + str = "Visual Studio 2011"; + break; + case 1600: + str = "Visual Studio 2010"; + break; + case 1500: + str = "Visual Studio 2008"; + break; + case 1400: + str = "Visual Studio 2005"; + break; + case 1310: + str = "Visual Studio 2003"; + break; + case 1300: + str = "Visual Studio 2002"; + break; + } } } else if( 0 == os.compare("Darwin")) { str = "Mac OS X :";