Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Treat warnings as errors with MSVC #500

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ build_script:
# Install Moco.
- mkdir ..\build
- cd ..\build
# Turn warnings into errors (/WX)
- cmake -E env CXXFLAGS="/WX" cmake ..\opensim-moco -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="C:\opensim-moco" -DADOLC_DIR="..\deps\adol-c" -DCMAKE_PREFIX_PATH="C:\projects\deps\eigen;C:\projects\deps\colpack;C:\projects\deps\opensim-core;C:\projects\deps\ipopt;C:\projects\deps\casadi;C:\projects\deps\casadi\casadi" -DMOCO_PYTHON_BINDINGS=ON -DMOCO_JAVA_BINDINGS=ON
- cmake ..\opensim-moco -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX="C:\opensim-moco" -DADOLC_DIR="..\deps\adol-c" -DCMAKE_PREFIX_PATH="C:\projects\deps\eigen;C:\projects\deps\colpack;C:\projects\deps\opensim-core;C:\projects\deps\ipopt;C:\projects\deps\casadi;C:\projects\deps\casadi\casadi" -DMOCO_PYTHON_BINDINGS=ON -DMOCO_JAVA_BINDINGS=ON
#-DCMAKE_TOOLCHAIN_FILE="C:\Tools\vcpkg\scripts\buildsystems\vcpkg.cmake"
- cmake --build . --config %BTYPE% -- /maxcpucount:4 /verbosity:minimal

Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang # includes AppleClang
add_compile_options(-Wno-unused-local-typedef)
endif()
endif()

# TODO add /WX flag for Windows.
if(MSVC)
# Treat warnings as errors.
# Ideally we would increase the warning level to 4 but that generates
# lots of 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()

enable_testing()
include(CTest)
Expand Down
2 changes: 1 addition & 1 deletion Moco/Moco/MocoGoal/MocoSumSquaredStateGoal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void MocoSumSquaredStateGoal::initializeOnModelImpl(const Model& model) const {

void MocoSumSquaredStateGoal::calcIntegrandImpl(
const SimTK::State& state, double& integrand) const {
for (int i = 0; i < m_state_weights.size(); ++i) {
for (int i = 0; i < (int)m_state_weights.size(); ++i) {
const auto& value = state.getY()[m_sysYIndices[i]];
integrand += m_state_weights[i] * value * value;
}
Expand Down
2 changes: 1 addition & 1 deletion Moco/Tests/testMocoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ TEMPLATE_TEST_CASE("Guess", "", MocoTropterSolver, MocoCasADiSolver) {
CHECK(explicitGuess.getDerivativeNames().empty());
explicitGuess.generateAccelerationsFromSpeeds();
// Only one coordinate in the sliding mass model.
CHECK(explicitGuess.getDerivativeNames().size() == 1);
CHECK((int)explicitGuess.getDerivativeNames().size() == 1);
}

// TODO ordering of states and controls in MocoTrajectory should not
Expand Down
4 changes: 2 additions & 2 deletions Moco/Tests/testTableProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TEST_CASE("TableProcessor") {

SECTION("Operators take effect") {
TableProcessor proc = TableProcessor(table) | MyTableOperator();
CHECK(proc.process().getNumRows() == 4);
CHECK((int)proc.process().getNumRows() == 4);
}

SECTION("Serialization") {
Expand All @@ -73,7 +73,7 @@ TEST_CASE("TableProcessor") {
"testTableProcessor_TableProcessor.xml"));
auto* proc = dynamic_cast<TableProcessor*>(obj.get());
TimeSeriesTable out = proc->process();
CHECK(out.getNumRows() == 4);
CHECK((int)out.getNumRows() == 4);
}
}
}
8 changes: 4 additions & 4 deletions tropter/tests/test_derivatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,13 +855,13 @@ class SparsityDetectionProblem : public Problem<T> {
VectorXd guess = decorator->make_initial_guess_from_bounds();
problem.guess = &guess;
solver.calc_sparsity(guess, jac_sparsity, false, hes_sparsity);
REQUIRE(jac_sparsity.row.size() == 3);
REQUIRE(jac_sparsity.col.size() == 3);
REQUIRE((int)jac_sparsity.row.size() == 3);
REQUIRE((int)jac_sparsity.col.size() == 3);

solver.set_sparsity_detection("random");
solver.calc_sparsity(guess, jac_sparsity, false, hes_sparsity);
REQUIRE(jac_sparsity.row.size() == 2);
REQUIRE(jac_sparsity.col.size() == 2);
REQUIRE((int)jac_sparsity.row.size() == 2);
REQUIRE((int)jac_sparsity.col.size() == 2);

REQUIRE_THROWS(solver.set_sparsity_detection("invalid"));
}
Expand Down
4 changes: 2 additions & 2 deletions tropter/tropter/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#ifdef _MSC_VER
// Ignore warnings from ADOL-C headers.
#pragma warning(push)
#pragma warning(push, 0)
// 'argument': conversion from 'size_t' to 'locint', possible loss of data.
#pragma warning(disable: 4267)
// #pragma warning(disable: 4267)
#endif
#include <adolc/adouble.h>
#ifdef _MSC_VER
Expand Down
7 changes: 7 additions & 0 deletions tropter/tropter/optimization/IPOPTSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@
#include "Problem.h"
#include <tropter/SparsityPattern.h>
#include <tropter/Exception.hpp>
#ifdef _MSC_VER
// Ignore warnings from Ipopt headers.
#pragma warning(push, 0)
#endif
#include <IpTNLP.hpp>
#include <IpIpoptApplication.hpp>
#include <IpIpoptData.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
using Eigen::VectorXd;
using Eigen::MatrixXd;
using Eigen::Ref;
Expand Down