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

Fix compile warnings #76

Merged
merged 13 commits into from
Jun 7, 2021
2 changes: 1 addition & 1 deletion BUILD-LINUX.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Prerequisites

* CMake (>= 3.12.0)
* GCC >= 5.0 or Clang >= 3.4
* GCC >= 7.0, Clang >= 3.9, or Intel C++ 18.0
* Optional: MATLAB R2009a or greater
* Optional: Git

Expand Down
2 changes: 1 addition & 1 deletion BUILD-OSX.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Prerequisites

* CMake (>= 3.12.0)
* GCC >= 5.0 or Clang >= 3.4
* GCC >= 7.0, Clang >= 3.9, or Intel C++ 18.0
* Optional: MATLAB R2009a or greater
* Optional: Git

Expand Down
2 changes: 1 addition & 1 deletion BUILD-WINDOWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Prerequisites

* CMake (>= 3.12.0)
* Microsoft Visual Studio 2015 (Community Edition, or better)
* Microsoft Visual Studio 2017 (Community Edition, or better) or Intel C++ 18.0
* Optional: MATLAB R2009a or greater
* Optional: Git
* Optional: Intel MKL
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ endif()
# ---------------------------------------------------

add_library(CADET::CompileOptions INTERFACE IMPORTED)
target_compile_features(CADET::CompileOptions INTERFACE cxx_std_14)
target_compile_features(CADET::CompileOptions INTERFACE cxx_std_17)
set(CMAKE_CXX_EXTENSIONS OFF)

if (WIN32)
Expand All @@ -491,6 +491,12 @@ if (ENABLE_PLATFORM_TIMER)
endif()
endif()

target_compile_options(CADET::CompileOptions INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -pedantic-errors -Wextra -Wno-unused-parameter -Wno-unused-function> #-Wconversion -Wsign-conversion
$<$<CXX_COMPILER_ID:MSVC>:
/W4>
)

add_library(CADET::AD INTERFACE IMPORTED)
if (ADLIB STREQUAL "sfad")
message(STATUS "AD library: SFAD")
Expand Down
4 changes: 4 additions & 0 deletions ThirdParty/pugixml/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8116,6 +8116,7 @@ PUGI__NS_BEGIN
return _data.variable->get_boolean();

// fallthrough to type conversion
[[fallthrough]];
}

default:
Expand Down Expand Up @@ -8252,6 +8253,7 @@ PUGI__NS_BEGIN
return _data.variable->get_number();

// fallthrough to type conversion
[[fallthrough]];
}

default:
Expand Down Expand Up @@ -8521,6 +8523,7 @@ PUGI__NS_BEGIN
return xpath_string_const(_data.variable->get_string());

// fallthrough to type conversion
[[fallthrough]];
}

default:
Expand Down Expand Up @@ -8670,6 +8673,7 @@ PUGI__NS_BEGIN
}

// fallthrough to type conversion
[[fallthrough]];
}

default:
Expand Down
1 change: 1 addition & 0 deletions include/cadet/HashUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "cadet/cadetCompilerInfo.hpp"

#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
Expand Down
1 change: 1 addition & 0 deletions include/cadet/ParameterProvider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <string>
#include <vector>
#include <cstdint>

#include "cadet/LibExportImport.hpp"
#include "cadet/cadetCompilerInfo.hpp"
Expand Down
8 changes: 4 additions & 4 deletions include/cadet/Simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class CADET_API ISimulator
* @param [out] len Length of the sensitivity state vector
* @return Array with pointers to sensitivity state vectors
*/
virtual const std::vector<double const*> getLastSensitivities(unsigned int& len) const = 0;
virtual std::vector<double const*> getLastSensitivities(unsigned int& len) const = 0;

/**
* @brief Returns the bare time derivative state vectors of the sensitivity subsystems for the last timepoint
Expand All @@ -496,14 +496,14 @@ class CADET_API ISimulator
* @param [out] len Length of the sensitivity state vector
* @return Array with pointers to sensitivity state vectors
*/
virtual const std::vector<double const*> getLastSensitivityDerivatives(unsigned int& len) const = 0;
virtual std::vector<double const*> getLastSensitivityDerivatives(unsigned int& len) const = 0;

/**
* @brief Returns the simulated model
* @return Simulated model or @c NULL
*/
virtual IModelSystem* const model() CADET_NOEXCEPT = 0;
virtual IModelSystem const* const model() const CADET_NOEXCEPT = 0;
virtual IModelSystem* model() CADET_NOEXCEPT = 0;
virtual IModelSystem const* model() const CADET_NOEXCEPT = 0;

/**
* @brief Return the number of DOFs in the current simulation
Expand Down
65 changes: 33 additions & 32 deletions include/cadet/StringUtil.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// =============================================================================
// CADET
//
//
// Copyright © 2008-2021: The CADET Authors
// Please see the AUTHORS and CONTRIBUTORS file.
//
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the GNU Public License v3.0 (or, at
// your option, any later version) which accompanies this distribution, and
// is available at http://www.gnu.org/licenses/gpl.html
// =============================================================================

/**
* @file
* @file
* Provides compile- and runtime string hashing
*/

Expand All @@ -20,6 +20,7 @@

#include "cadet/cadetCompilerInfo.hpp"

#include <cstddef>
#include <cstdint>
#include <cctype>
#include <string>
Expand Down Expand Up @@ -51,13 +52,13 @@ CADET_CONSTEXPR static inline sip_word rotl64(const sip_word word, const unsigne
class ConstString
{
public:
template<size_t N>
template<std::size_t N>
constexpr ConstString(const char(&s)[N]) : m_Str(s), m_Size(N - 1) { }
constexpr ConstString(const char* s, size_t len) : m_Str(s), m_Size(len) { }
constexpr size_t size() const { return m_Size; }
constexpr unsigned char operator[] (size_t n) const
constexpr ConstString(const char* s, std::size_t len) : m_Str(s), m_Size(len) { }

constexpr std::size_t size() const { return m_Size; }

constexpr unsigned char operator[] (std::size_t n) const
{
return static_cast<unsigned char>(m_Str[n]);
}
Expand All @@ -74,7 +75,7 @@ CADET_CONSTEXPR static inline sip_word rotl64(const sip_word word, const unsigne
}

private:

/**
* @brief 256 bit state
*/
Expand Down Expand Up @@ -135,12 +136,12 @@ CADET_CONSTEXPR static inline sip_word rotl64(const sip_word word, const unsigne
return (rounds > 0) ? mixLoop(mix(s), rounds - 1) : s;
}

constexpr static inline sip_word tailWordInternal(const ConstString& cs, const sip_word tailWord, const size_t offset, const unsigned int tailSize)
constexpr static inline sip_word tailWordInternal(const ConstString& cs, const sip_word tailWord, const std::size_t offset, const unsigned int tailSize)
{
return (tailSize == 0) ? tailWord : tailWordInternal(cs, tailWord | (static_cast<sip_word>(cs[offset + tailSize - 1]) << ((tailSize - 1) * 8)), offset, tailSize - 1);
}

constexpr static inline sip_word tailWord(const ConstString& cs, const size_t offset, const size_t insize)
constexpr static inline sip_word tailWord(const ConstString& cs, const std::size_t offset, const std::size_t insize)
{
return tailWordInternal(cs, static_cast<sip_word>(insize) << 56, offset, insize & 7);
}
Expand Down Expand Up @@ -189,7 +190,7 @@ CADET_CONSTEXPR static inline sip_word rotl64(const sip_word word, const unsigne
}

const char* m_Str;
size_t m_Size;
std::size_t m_Size;
};

#endif
Expand All @@ -216,26 +217,26 @@ static inline sip_word read64(unsigned char const* const p)
*/
static inline void mix(sip_word &state0, sip_word &state1, sip_word &state2, sip_word &state3)
{
state0 += state1;
state0 += state1;
state2 += state3;
state1 = rotl64(state1, 13);
state1 = rotl64(state1, 13);
state3 = rotl64(state3, 16);
state1 ^= state0;
state3 ^= state2;
state0 = rotl64(state0, 32);
state2 += state1;
state0 += state3;
state1 = rotl64(state1, 17);
state1 = rotl64(state1, 17);
state3 = rotl64(state3, 21);
state1 ^= state2;
state1 ^= state2;
state3 ^= state0;
state2 = rotl64(state2, 32);
}

/**
* @brief Computes the SipHash value of the given data at runtime
* @details Implementation taken from https://chiselapp.com/user/Justin_be_my_guide/repository/siple/artifact/f7d1b255a09c1d67
*
*
* @param [in] in Input data
* @param [in] insize Size of the input data (in byte)
* @param [in] key0 Arbitrary key (defaults to 0)
Expand All @@ -245,7 +246,7 @@ static inline void mix(sip_word &state0, sip_word &state1, sip_word &state2, sip
* @return SipHash value of the given data
*/
template<const int rounds, const int finalisation_rounds>
static inline sip_word siphash(const void *in, const size_t insize, const sip_word key0 = 0, const sip_word key1 = 0)
static inline sip_word siphash(const void *in, const std::size_t insize, const sip_word key0 = 0, const sip_word key1 = 0)
{
sip_word state0 = key0 ^ 0x736f6d6570736575ull;
sip_word state1 = key1 ^ 0x646f72616e646f6dull;
Expand All @@ -272,13 +273,13 @@ static inline sip_word siphash(const void *in, const size_t insize, const sip_wo

switch (tail_size)
{
case 7: tail_word |= (sip_word)char_in[6] << 48;
case 6: tail_word |= (sip_word)char_in[5] << 40;
case 5: tail_word |= (sip_word)char_in[4] << 32;
case 4: tail_word |= (sip_word)char_in[3] << 24;
case 3: tail_word |= (sip_word)char_in[2] << 16;
case 2: tail_word |= (sip_word)char_in[1] << 8;
case 1: tail_word |= (sip_word)char_in[0];
case 7: tail_word |= (sip_word)char_in[6] << 48; [[fallthrough]];
case 6: tail_word |= (sip_word)char_in[5] << 40; [[fallthrough]];
case 5: tail_word |= (sip_word)char_in[4] << 32; [[fallthrough]];
case 4: tail_word |= (sip_word)char_in[3] << 24; [[fallthrough]];
case 3: tail_word |= (sip_word)char_in[2] << 16; [[fallthrough]];
case 2: tail_word |= (sip_word)char_in[1] << 8; [[fallthrough]];
case 1: tail_word |= (sip_word)char_in[0]; [[fallthrough]];
case 0: break;
}

Expand All @@ -303,7 +304,7 @@ static inline sip_word siphash(const void *in, const size_t insize, const sip_wo
/**
* @brief Computes the SipHash24 value of the given string at runtime
* @details Computes a 64 bit hash value of the string at runtime
*
*
* @param [in] str String
* @param [in] key0 Arbitrary key (defaults to 0)
* @param [in] key1 Arbitrary key (defaults to 0)
Expand All @@ -317,7 +318,7 @@ inline StringHash SipHash24runtime(const std::string& str, const StringHash key0
/**
* @brief Computes the SipHash24 value of the given string at runtime
* @details Computes a 64 bit hash value of the string at runtime
*
*
* @param [in] str String
* @param [in] key0 Arbitrary key (defaults to 0)
* @param [in] key1 Arbitrary key (defaults to 0)
Expand All @@ -335,7 +336,7 @@ inline StringHash SipHash24runtime(char const* const str, const StringHash key0
/**
* @brief Computes the SipHash24 value of the given string
* @details Computes a 64 bit hash value of the string at compiletime
*
*
* @param [in] cs Compiletime string
* @param [in] key0 Arbitrary key (defaults to 0)
* @param [in] key1 Arbitrary key (defaults to 0)
Expand All @@ -351,7 +352,7 @@ inline StringHash SipHash24runtime(char const* const str, const StringHash key0
/**
* @brief Computes the SipHash24 value of the given string at runtime
* @details Computes a 64 bit hash value of the string at runtime
*
*
* @param [in] str String
* @param [in] key0 Arbitrary key (defaults to 0)
* @param [in] key1 Arbitrary key (defaults to 0)
Expand Down Expand Up @@ -390,12 +391,12 @@ inline bool caseInsensitiveEquals(const std::string& a, const std::string& b)
/**
* @brief Computes the SipHash24 value of the given string
* @details Computes a 64 bit hash value of the string at compiletime using SipHash24 with both keys 0
*
*
* @param [in] str Compiletime string
* @param [in] len Length of the compiletime string
* @return SipHash24 value of the given compiletime string
*/
constexpr StringHash operator "" _hash(const char* str, size_t len)
constexpr StringHash operator "" _hash(const char* str, std::size_t len)
{
return util::hash::ConstString(str, len).hash();
}
Expand Down
4 changes: 2 additions & 2 deletions include/common/Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Driver
// Convert to ParameterIds
std::vector<cadet::ParameterId> sensParams;
sensParams.reserve(sensName.size());
for (unsigned int i = 0; i < sensName.size(); ++i)
for (std::size_t i = 0; i < sensName.size(); ++i)
sensParams.push_back(cadet::makeParamId(sensName[i], sensUnit[i], sensComp[i], sensParType[i], sensBoundState[i], sensReaction[i], sensSection[i]));

double sensTol = 1e-05;
Expand Down Expand Up @@ -535,7 +535,7 @@ class Driver
const std::vector<double const*> lastYdot = _sim->getLastSensitivityDerivatives(len);

std::ostringstream oss;
for (unsigned int i = 0; i < lastY.size(); ++i)
for (std::size_t i = 0; i < lastY.size(); ++i)
{
oss.str("");
oss << "LAST_STATE_SENSY_" << std::setfill('0') << std::setw(3) << std::setprecision(0) << i;
Expand Down
14 changes: 4 additions & 10 deletions include/common/JsonParameterProvider.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// =============================================================================
// CADET
//
//
// Copyright © 2008-2021: The CADET Authors
// Please see the AUTHORS and CONTRIBUTORS file.
//
//
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the GNU Public License v3.0 (or, at
// your option, any later version) which accompanies this distribution, and
// is available at http://www.gnu.org/licenses/gpl.html
// =============================================================================

/**
* @file
* @file
* Defines a ParameterProvider that uses JSON.
*/

Expand All @@ -24,13 +24,7 @@
#include <string>
#include <stack>
#include <ostream>

#ifndef CADET_JSONPARAMETERPROVIDER_NOFORWARD
namespace nlohmann
{
class json;
}
#endif
#include <json.hpp>

namespace cadet
{
Expand Down
2 changes: 1 addition & 1 deletion include/common/LoggerBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace log
os << "[";
if (!v.empty())
{
for (unsigned int i = 0; i < v.size()-1; ++i)
for (std::size_t i = 0; i < v.size()-1; ++i)
os << v[i] << ",";
os << v.back();
}
Expand Down