Skip to content
Snippets Groups Projects
Commit 925fa984 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

fix fallthrough warning

fix:
…/sot-core/src/tools/device.cpp: In member function ‘virtual void dynamicgraph::sot::Device::setState(const Vector&)’:
…/sot-core/src/tools/device.cpp:248:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
       }
       ^
…/sot-core/src/tools/device.cpp:249:5: note: here
     case CONTROL_INPUT_ONE_INTEGRATION:
     ^~~~
parent c18cde6d
No related branches found
No related tags found
No related merge requests found
......@@ -111,6 +111,7 @@ SET(${PROJECT_NAME}_HEADERS
include/${CUSTOM_HEADER_DIR}/joint-limitator.hh
include/${CUSTOM_HEADER_DIR}/kalman.hh
include/${CUSTOM_HEADER_DIR}/latch.hh
include/${CUSTOM_HEADER_DIR}/macros.hh
include/${CUSTOM_HEADER_DIR}/macros-signal.hh
include/${CUSTOM_HEADER_DIR}/mailbox-vector.hh
include/${CUSTOM_HEADER_DIR}/mailbox.hh
......
#ifndef __SOT_CORE_MACROS_HH__
#define __SOT_CORE_MACROS_HH__
// ref https://www.fluentcpp.com/2019/08/30/how-to-disable-a-warning-in-cpp/
#if defined(_MSC_VER)
#define SOT_CORE_DISABLE_WARNING_PUSH __pragma(warning( push ))
#define SOT_CORE_DISABLE_WARNING_POP __pragma(warning( pop ))
#define SOT_CORE_DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
#define SOT_CORE_DISABLE_WARNING_DEPRECATED SOT_CORE_DISABLE_WARNING(4996)
#define SOT_CORE_DISABLE_WARNING_FALLTHROUGH
#elif defined(__GNUC__) || defined(__clang__)
#define SOT_CORE_DO_PRAGMA(X) _Pragma(#X)
#define SOT_CORE_DISABLE_WARNING_PUSH SOT_CORE_DO_PRAGMA(GCC diagnostic push)
#define SOT_CORE_DISABLE_WARNING_POP SOT_CORE_DO_PRAGMA(GCC diagnostic pop)
#define SOT_CORE_DISABLE_WARNING(warningName) SOT_CORE_DO_PRAGMA(GCC diagnostic ignored #warningName)
#define SOT_CORE_DISABLE_WARNING_DEPRECATED SOT_CORE_DISABLE_WARNING(-Wdeprecated-declarations)
#define SOT_CORE_DISABLE_WARNING_FALLTHROUGH SOT_CORE_DISABLE_WARNING(-Wimplicit-fallthrough)
#else
#define SOT_CORE_DISABLE_WARNING_PUSH
#define SOT_CORE_DISABLE_WARNING_POP
#define SOT_CORE_DISABLE_WARNING_DEPRECATED
#endif
#endif
......@@ -15,6 +15,7 @@
#include "sot/core/device.hh"
#include <iostream>
#include <sot/core/macros.hh>
#include <sot/core/debug.hh>
using namespace std;
......@@ -229,6 +230,8 @@ void Device::setVelocitySize(const unsigned int &size) {
void Device::setState(const Vector &st) {
if (sanityCheck_) {
const Vector::Index &s = st.size();
SOT_CORE_DISABLE_WARNING_PUSH
SOT_CORE_DISABLE_WARNING_FALLTHROUGH
switch (controlInputType_) {
case CONTROL_INPUT_TWO_INTEGRATION:
dgRTLOG()
......@@ -263,6 +266,7 @@ void Device::setState(const Vector &st) {
default:
throw std::invalid_argument("Invalid control mode type.");
}
SOT_CORE_DISABLE_WARNING_POP
}
state_ = st;
stateSOUT.setConstant(state_);
......@@ -315,6 +319,8 @@ void Device::setControlInputType(const std::string &cit) {
void Device::setSanityCheck(const bool &enableCheck) {
if (enableCheck) {
const Vector::Index &s = state_.size();
SOT_CORE_DISABLE_WARNING_PUSH
SOT_CORE_DISABLE_WARNING_FALLTHROUGH
switch (controlInputType_) {
case CONTROL_INPUT_TWO_INTEGRATION:
dgRTLOG()
......@@ -341,6 +347,7 @@ void Device::setSanityCheck(const bool &enableCheck) {
default:
throw std::invalid_argument("Invalid control mode type.");
}
SOT_CORE_DISABLE_WARNING_POP
}
sanityCheck_ = enableCheck;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment