Skip to content

Commit

Permalink
Fix GetCompilerVersion for VS2017; fix VS2017 warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdembia committed Aug 23, 2017
1 parent 8ff07f2 commit 1c920e5
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 41 deletions.
6 changes: 3 additions & 3 deletions Applications/Analyze/test/testAnalyzeTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(mf, forces[i], equilTol, __FILE__, __LINE__,
" Analyze reported force: " << forces[int(i)] << endl;
ASSERT_EQUAL<double>(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.");
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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++. "
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Analyses/InverseDynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ begin(SimTK::State& s )
for(size_t i=0u; i<coordinates.size(); ++i) {
const Coordinate& coord = *coordinates[i];
if(!coord.isConstrained(sWorkingCopy)) {
_accelerationIndices.append(i);
_accelerationIndices.append(static_cast<int>(i));
}
}

Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Analyses/StaticOptimizationTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(i));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Common/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsigned>(len));
maxlen = std::max(maxlen, len);
}

if (numSubcomponents == 0) {
Expand Down
2 changes: 1 addition & 1 deletion OpenSim/Common/ComponentSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class Input : public AbstractInput {
SimTK::Vector_<T>. The elements are in the same order as the channels.
*/
SimTK::Vector_<T> getVector(const SimTK::State& state) const {
SimTK::Vector_<T> v(_connectees.size());
SimTK::Vector_<T> v(static_cast<int>(_connectees.size()));
for (unsigned ichan = 0u; ichan < _connectees.size(); ++ichan) {
v[ichan] = _connectees[ichan]->getValue(state);
}
Expand Down
4 changes: 4 additions & 0 deletions OpenSim/Common/Test/testComponentInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,8 @@ void testAliasesAndLabels() {
SimTK_TEST(foo->getInput("listInput1").getLabel(1) == "thud");
}

#include <OpenSim/version.h>

int main() {

//Register new types for testing deserialization
Expand Down Expand Up @@ -2022,5 +2024,7 @@ int main() {
SimTK_SUBTEST(testListInputConnecteeSerialization);
SimTK_SUBTEST(testSingleValueInputConnecteeSerialization);

std::cout << OpenSim::GetCompilerVersion() << std::endl;

SimTK_END_TEST();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Simulation/SimbodyEngine/SimbodyEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand All @@ -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){
Expand Down
74 changes: 45 additions & 29 deletions OpenSim/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 :";
Expand Down

0 comments on commit 1c920e5

Please sign in to comment.