Commit 1f314a5e by Maarten L. Hekkelman

removing compiler warnings on MSVC

parent 0adb50ac
...@@ -98,33 +98,33 @@ if(BUILD_FOR_CCP4) ...@@ -98,33 +98,33 @@ if(BUILD_FOR_CCP4)
endif() endif()
endif() endif()
if(WIN32)
if(${CMAKE_SYSTEM_VERSION} GREATER_EQUAL 10) # Windows 10
add_definitions(-D _WIN32_WINNT=0x0A00)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.3) # Windows 8.1
add_definitions(-D _WIN32_WINNT=0x0603)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.2) # Windows 8
add_definitions(-D _WIN32_WINNT=0x0602)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.1) # Windows 7
add_definitions(-D _WIN32_WINNT=0x0601)
elseif(${CMAKE_SYSTEM_VERSION} EQUAL 6.0) # Windows Vista
add_definitions(-D _WIN32_WINNT=0x0600)
else() # Windows XP (5.1)
add_definitions(-D _WIN32_WINNT=0x0501)
endif()
add_definitions(-DNOMINMAX)
endif()
if(MSVC) if(MSVC)
# make msvc standards compliant... # make msvc standards compliant...
add_compile_options(/permissive-) add_compile_options(/permissive-)
macro(get_WIN32_WINNT version) if(BUILD_SHARED_LIBS)
if(CMAKE_SYSTEM_VERSION) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set(ver ${CMAKE_SYSTEM_VERSION}) else()
string(REGEX MATCH "^([0-9]+).([0-9])" ver ${ver}) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
string(REGEX MATCH "^([0-9]+)" verMajor ${ver})
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if("${verMajor}" MATCHES "10")
set(verMajor "A")
string(REGEX REPLACE "^([0-9]+)" ${verMajor} ver ${ver})
endif()
# Remove all remaining '.' characters.
string(REPLACE "." "" ver ${ver})
# Prepend each digit with a zero.
string(REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ver})
set(${version} "0x${ver}")
endif() endif()
endmacro()
get_WIN32_WINNT(ver)
add_definitions(-D_WIN32_WINNT=${ver})
endif() endif()
# Libraries # Libraries
......
...@@ -44,24 +44,24 @@ template <typename M> ...@@ -44,24 +44,24 @@ template <typename M>
class matrix_expression class matrix_expression
{ {
public: public:
constexpr uint32_t dim_m() const { return static_cast<const M &>(*this).dim_m(); } constexpr size_t dim_m() const { return static_cast<const M &>(*this).dim_m(); }
constexpr uint32_t dim_n() const { return static_cast<const M &>(*this).dim_n(); } constexpr size_t dim_n() const { return static_cast<const M &>(*this).dim_n(); }
constexpr bool empty() const { return dim_m() == 0 or dim_n() == 0; } constexpr bool empty() const { return dim_m() == 0 or dim_n() == 0; }
constexpr auto &operator()(uint32_t i, uint32_t j) constexpr auto &operator()(size_t i, size_t j)
{ {
return static_cast<M &>(*this).operator()(i, j); return static_cast<M &>(*this).operator()(i, j);
} }
constexpr auto operator()(uint32_t i, uint32_t j) const constexpr auto operator()(size_t i, size_t j) const
{ {
return static_cast<const M &>(*this).operator()(i, j); return static_cast<const M &>(*this).operator()(i, j);
} }
void swap_row(uint32_t r1, uint32_t r2) void swap_row(size_t r1, size_t r2)
{ {
for (uint32_t c = 0; c < dim_m(); ++c) for (size_t c = 0; c < dim_m(); ++c)
{ {
auto v = operator()(r1, c); auto v = operator()(r1, c);
operator()(r1, c) = operator()(r2, c); operator()(r1, c) = operator()(r2, c);
...@@ -69,9 +69,9 @@ class matrix_expression ...@@ -69,9 +69,9 @@ class matrix_expression
} }
} }
void swap_col(uint32_t c1, uint32_t c2) void swap_col(size_t c1, size_t c2)
{ {
for (uint32_t r = 0; r < dim_n(); ++r) for (size_t r = 0; r < dim_n(); ++r)
{ {
auto &a = operator()(r, c1); auto &a = operator()(r, c1);
auto &b = operator()(r, c2); auto &b = operator()(r, c2);
...@@ -122,9 +122,9 @@ class matrix : public matrix_expression<matrix<F>> ...@@ -122,9 +122,9 @@ class matrix : public matrix_expression<matrix<F>>
, m_n(m.dim_n()) , m_n(m.dim_n())
, m_data(m_m * m_n) , m_data(m_m * m_n)
{ {
for (uint32_t i = 0; i < m_m; ++i) for (size_t i = 0; i < m_m; ++i)
{ {
for (uint32_t j = 0; j < m_n; ++j) for (size_t j = 0; j < m_n; ++j)
operator()(i, j) = m(i, j); operator()(i, j) = m(i, j);
} }
} }
...@@ -180,9 +180,9 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>> ...@@ -180,9 +180,9 @@ class matrix_fixed : public matrix_expression<matrix_fixed<F, M, N>>
matrix_fixed(const M2 &m) matrix_fixed(const M2 &m)
{ {
assert(M == m.dim_m() and N == m.dim_n()); assert(M == m.dim_m() and N == m.dim_n());
for (uint32_t i = 0; i < M; ++i) for (size_t i = 0; i < M; ++i)
{ {
for (uint32_t j = 0; j < N; ++j) for (size_t j = 0; j < N; ++j)
operator()(i, j) = m(i, j); operator()(i, j) = m(i, j);
} }
} }
...@@ -244,7 +244,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>> ...@@ -244,7 +244,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
public: public:
using value_type = F; using value_type = F;
symmetric_matrix(uint32_t n, value_type v = 0) symmetric_matrix(size_t n, value_type v = 0)
: m_n(n) : m_n(n)
, m_data((m_n * (m_n + 1)) / 2) , m_data((m_n * (m_n + 1)) / 2)
{ {
...@@ -257,17 +257,17 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>> ...@@ -257,17 +257,17 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
symmetric_matrix &operator=(symmetric_matrix &&m) = default; symmetric_matrix &operator=(symmetric_matrix &&m) = default;
symmetric_matrix &operator=(const symmetric_matrix &m) = default; symmetric_matrix &operator=(const symmetric_matrix &m) = default;
constexpr uint32_t dim_m() const { return m_n; } constexpr size_t dim_m() const { return m_n; }
constexpr uint32_t dim_n() const { return m_n; } constexpr size_t dim_n() const { return m_n; }
constexpr value_type operator()(uint32_t i, uint32_t j) const constexpr value_type operator()(size_t i, size_t j) const
{ {
return i < j return i < j
? m_data[(j * (j + 1)) / 2 + i] ? m_data[(j * (j + 1)) / 2 + i]
: m_data[(i * (i + 1)) / 2 + j]; : m_data[(i * (i + 1)) / 2 + j];
} }
constexpr value_type &operator()(uint32_t i, uint32_t j) constexpr value_type &operator()(size_t i, size_t j)
{ {
if (i > j) if (i > j)
std::swap(i, j); std::swap(i, j);
...@@ -276,7 +276,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>> ...@@ -276,7 +276,7 @@ class symmetric_matrix : public matrix_expression<symmetric_matrix<F>>
} }
private: private:
uint32_t m_n; size_t m_n;
std::vector<value_type> m_data; std::vector<value_type> m_data;
}; };
...@@ -298,17 +298,17 @@ class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F ...@@ -298,17 +298,17 @@ class symmetric_matrix_fixed : public matrix_expression<symmetric_matrix_fixed<F
symmetric_matrix_fixed &operator=(symmetric_matrix_fixed &&m) = default; symmetric_matrix_fixed &operator=(symmetric_matrix_fixed &&m) = default;
symmetric_matrix_fixed &operator=(const symmetric_matrix_fixed &m) = default; symmetric_matrix_fixed &operator=(const symmetric_matrix_fixed &m) = default;
constexpr uint32_t dim_m() const { return M; } constexpr size_t dim_m() const { return M; }
constexpr uint32_t dim_n() const { return M; } constexpr size_t dim_n() const { return M; }
constexpr value_type operator()(uint32_t i, uint32_t j) const constexpr value_type operator()(size_t i, size_t j) const
{ {
return i < j return i < j
? m_data[(j * (j + 1)) / 2 + i] ? m_data[(j * (j + 1)) / 2 + i]
: m_data[(i * (i + 1)) / 2 + j]; : m_data[(i * (i + 1)) / 2 + j];
} }
constexpr value_type &operator()(uint32_t i, uint32_t j) constexpr value_type &operator()(size_t i, size_t j)
{ {
if (i > j) if (i > j)
std::swap(i, j); std::swap(i, j);
...@@ -334,21 +334,21 @@ class identity_matrix : public matrix_expression<identity_matrix<F>> ...@@ -334,21 +334,21 @@ class identity_matrix : public matrix_expression<identity_matrix<F>>
public: public:
using value_type = F; using value_type = F;
identity_matrix(uint32_t n) identity_matrix(size_t n)
: m_n(n) : m_n(n)
{ {
} }
constexpr uint32_t dim_m() const { return m_n; } constexpr size_t dim_m() const { return m_n; }
constexpr uint32_t dim_n() const { return m_n; } constexpr size_t dim_n() const { return m_n; }
constexpr value_type operator()(uint32_t i, uint32_t j) const constexpr value_type operator()(size_t i, size_t j) const
{ {
return i == j ? 1 : 0; return static_cast<value_type>(i == j ? 1 : 0);
} }
private: private:
uint32_t m_n; size_t m_n;
}; };
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -366,10 +366,10 @@ class matrix_subtraction : public matrix_expression<matrix_subtraction<M1, M2>> ...@@ -366,10 +366,10 @@ class matrix_subtraction : public matrix_expression<matrix_subtraction<M1, M2>>
assert(m_m1.dim_n() == m_m2.dim_n()); assert(m_m1.dim_n() == m_m2.dim_n());
} }
constexpr uint32_t dim_m() const { return m_m1.dim_m(); } constexpr size_t dim_m() const { return m_m1.dim_m(); }
constexpr uint32_t dim_n() const { return m_m1.dim_n(); } constexpr size_t dim_n() const { return m_m1.dim_n(); }
constexpr auto operator()(uint32_t i, uint32_t j) const constexpr auto operator()(size_t i, size_t j) const
{ {
return m_m1(i, j) - m_m2(i, j); return m_m1(i, j) - m_m2(i, j);
} }
...@@ -396,16 +396,16 @@ class matrix_matrix_multiplication : public matrix_expression<matrix_matrix_mult ...@@ -396,16 +396,16 @@ class matrix_matrix_multiplication : public matrix_expression<matrix_matrix_mult
assert(m1.dim_m() == m2.dim_n()); assert(m1.dim_m() == m2.dim_n());
} }
constexpr uint32_t dim_m() const { return m_m1.dim_m(); } constexpr size_t dim_m() const { return m_m1.dim_m(); }
constexpr uint32_t dim_n() const { return m_m1.dim_n(); } constexpr size_t dim_n() const { return m_m1.dim_n(); }
constexpr auto operator()(uint32_t i, uint32_t j) const constexpr auto operator()(size_t i, size_t j) const
{ {
using value_type = decltype(m_m1(0, 0)); using value_type = decltype(m_m1(0, 0));
value_type result = {}; value_type result = {};
for (uint32_t k = 0; k < m_m1.dim_m(); ++k) for (size_t k = 0; k < m_m1.dim_m(); ++k)
result += m_m1(i, k) * m_m2(k, j); result += m_m1(i, k) * m_m2(k, j);
return result; return result;
...@@ -428,10 +428,10 @@ class matrix_scalar_multiplication : public matrix_expression<matrix_scalar_mult ...@@ -428,10 +428,10 @@ class matrix_scalar_multiplication : public matrix_expression<matrix_scalar_mult
{ {
} }
constexpr uint32_t dim_m() const { return m_m.dim_m(); } constexpr size_t dim_m() const { return m_m.dim_m(); }
constexpr uint32_t dim_n() const { return m_m.dim_n(); } constexpr size_t dim_n() const { return m_m.dim_n(); }
constexpr auto operator()(uint32_t i, uint32_t j) const constexpr auto operator()(size_t i, size_t j) const
{ {
return m_m(i, j) * m_v; return m_m(i, j) * m_v;
} }
...@@ -500,10 +500,10 @@ class matrix_cofactors : public matrix_expression<matrix_cofactors<M>> ...@@ -500,10 +500,10 @@ class matrix_cofactors : public matrix_expression<matrix_cofactors<M>>
{ {
} }
constexpr uint32_t dim_m() const { return m_m.dim_m(); } constexpr size_t dim_m() const { return m_m.dim_m(); }
constexpr uint32_t dim_n() const { return m_m.dim_n(); } constexpr size_t dim_n() const { return m_m.dim_n(); }
constexpr auto operator()(uint32_t i, uint32_t j) const constexpr auto operator()(size_t i, size_t j) const
{ {
const size_t ixs[4][3] = { const size_t ixs[4][3] = {
{ 1, 2, 3 }, { 1, 2, 3 },
......
...@@ -184,7 +184,7 @@ class datablock; ...@@ -184,7 +184,7 @@ class datablock;
class cell; class cell;
class spacegroup; class spacegroup;
class rtop; class rtop;
class sym_op; struct sym_op;
/// @brief A class that encapsulates the symmetry operations as used in PDB files, i.e. a rotational number and a translation vector /// @brief A class that encapsulates the symmetry operations as used in PDB files, i.e. a rotational number and a translation vector
......
...@@ -1976,13 +1976,13 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool ...@@ -1976,13 +1976,13 @@ void category::write(std::ostream &os, const std::vector<uint16_t> &order, bool
if (s.empty()) if (s.empty())
s = "?"; s = "?";
size_t l = s.length(); size_t l2 = s.length();
if (not sac_parser::is_unquoted_string(s)) if (not sac_parser::is_unquoted_string(s))
l += 2; l2 += 2;
if (width < l) if (width < l2)
width = l; width = l2;
} }
for (uint16_t cix : order) for (uint16_t cix : order)
......
...@@ -61,7 +61,7 @@ quaternion_type<T> normalize(quaternion_type<T> q) ...@@ -61,7 +61,7 @@ quaternion_type<T> normalize(quaternion_type<T> q)
quaternion construct_from_angle_axis(float angle, point axis) quaternion construct_from_angle_axis(float angle, point axis)
{ {
angle = (angle * kPI / 180) / 2; angle = static_cast<float>((angle * kPI / 180) / 2);
auto s = std::sin(angle); auto s = std::sin(angle);
auto c = std::cos(angle); auto c = std::cos(angle);
...@@ -119,7 +119,7 @@ point center_points(std::vector<point> &Points) ...@@ -119,7 +119,7 @@ point center_points(std::vector<point> &Points)
} }
quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4, quaternion construct_for_dihedral_angle(point p1, point p2, point p3, point p4,
float angle, float esd) float angle, float /*esd*/)
{ {
p1 -= p3; p1 -= p3;
p2 -= p3; p2 -= p3;
......
...@@ -70,12 +70,12 @@ void cell::init() ...@@ -70,12 +70,12 @@ void cell::init()
m_orthogonal = identity_matrix(3); m_orthogonal = identity_matrix(3);
m_orthogonal(0, 0) = m_a; m_orthogonal(0, 0) = static_cast<float>(m_a);
m_orthogonal(0, 1) = m_b * std::cos(gamma); m_orthogonal(0, 1) = static_cast<float>(m_b * std::cos(gamma));
m_orthogonal(0, 2) = m_c * std::cos(beta); m_orthogonal(0, 2) = static_cast<float>(m_c * std::cos(beta));
m_orthogonal(1, 1) = m_b * std::sin(gamma); m_orthogonal(1, 1) = static_cast<float>(m_b * std::sin(gamma));
m_orthogonal(1, 2) = -m_c * std::sin(beta) * std::cos(alpha_star); m_orthogonal(1, 2) = static_cast<float>(-m_c * std::sin(beta) * std::cos(alpha_star));
m_orthogonal(2, 2) = m_c * std::sin(beta) * std::sin(alpha_star); m_orthogonal(2, 2) = static_cast<float>(m_c * std::sin(beta) * std::sin(alpha_star));
m_fractional = inverse(m_orthogonal); m_fractional = inverse(m_orthogonal);
} }
...@@ -90,7 +90,7 @@ sym_op::sym_op(std::string_view s) ...@@ -90,7 +90,7 @@ sym_op::sym_op(std::string_view s)
int rnri = 256; // default to unexisting number int rnri = 256; // default to unexisting number
auto r = std::from_chars(b, e, rnri); auto r = std::from_chars(b, e, rnri);
m_nr = rnri; m_nr = static_cast<uint8_t>(rnri);
m_ta = r.ptr[1] - '0'; m_ta = r.ptr[1] - '0';
m_tb = r.ptr[2] - '0'; m_tb = r.ptr[2] - '0';
m_tc = r.ptr[3] - '0'; m_tc = r.ptr[3] - '0';
...@@ -121,21 +121,21 @@ transformation::transformation(const symop_data &data) ...@@ -121,21 +121,21 @@ transformation::transformation(const symop_data &data)
{ {
const auto &d = data.data(); const auto &d = data.data();
m_rotation(0, 0) = d[0]; m_rotation(0, 0) = static_cast<float>(d[0]);
m_rotation(0, 1) = d[1]; m_rotation(0, 1) = static_cast<float>(d[1]);
m_rotation(0, 2) = d[2]; m_rotation(0, 2) = static_cast<float>(d[2]);
m_rotation(1, 0) = d[3]; m_rotation(1, 0) = static_cast<float>(d[3]);
m_rotation(1, 1) = d[4]; m_rotation(1, 1) = static_cast<float>(d[4]);
m_rotation(1, 2) = d[5]; m_rotation(1, 2) = static_cast<float>(d[5]);
m_rotation(2, 0) = d[6]; m_rotation(2, 0) = static_cast<float>(d[6]);
m_rotation(2, 1) = d[7]; m_rotation(2, 1) = static_cast<float>(d[7]);
m_rotation(2, 2) = d[8]; m_rotation(2, 2) = static_cast<float>(d[8]);
try_create_quaternion(); try_create_quaternion();
m_translation.m_x = d[9] == 0 ? 0 : 1.0 * d[9] / d[10]; m_translation.m_x = static_cast<float>(d[9] == 0 ? 0 : 1.0 * d[9] / d[10]);
m_translation.m_y = d[11] == 0 ? 0 : 1.0 * d[11] / d[12]; m_translation.m_y = static_cast<float>(d[11] == 0 ? 0 : 1.0 * d[11] / d[12]);
m_translation.m_z = d[13] == 0 ? 0 : 1.0 * d[13] / d[14]; m_translation.m_z = static_cast<float>(d[13] == 0 ? 0 : 1.0 * d[13] / d[14]);
} }
transformation::transformation(const matrix3x3<float> &r, const cif::point &t) transformation::transformation(const matrix3x3<float> &r, const cif::point &t)
...@@ -461,7 +461,7 @@ std::tuple<float,point,sym_op> crystal::closest_symmetry_copy(point a, point b) ...@@ -461,7 +461,7 @@ std::tuple<float,point,sym_op> crystal::closest_symmetry_copy(point a, point b)
for (size_t i = 0; i < m_spacegroup.size(); ++i) for (size_t i = 0; i < m_spacegroup.size(); ++i)
{ {
sym_op s(i + 1); sym_op s(static_cast<uint8_t>(i + 1));
auto &t = m_spacegroup[i]; auto &t = m_spacegroup[i];
auto fsb = t(fb); auto fsb = t(fb);
......
...@@ -239,7 +239,7 @@ std::string cif_id_for_number(int number) ...@@ -239,7 +239,7 @@ std::string cif_id_for_number(int number)
do do
{ {
int r = number % 26; int r = number % 26;
result += 'A' + r; result += static_cast<char>('A' + r);
number = (number - r) / 26 - 1; number = (number - r) / 26 - 1;
} }
......
...@@ -204,7 +204,7 @@ void progress_bar_impl::run() ...@@ -204,7 +204,7 @@ void progress_bar_impl::run()
std::lock_guard lock(m_mutex); std::lock_guard lock(m_mutex);
if (not printedAny and isatty(STDOUT_FILENO)) if (not printedAny and isatty(STDOUT_FILENO))
std::cout << "\e[?25l"; std::cout << "\x1b[?25l";
print_progress(); print_progress();
...@@ -220,7 +220,7 @@ void progress_bar_impl::run() ...@@ -220,7 +220,7 @@ void progress_bar_impl::run()
{ {
print_done(); print_done();
if (isatty(STDOUT_FILENO)) if (isatty(STDOUT_FILENO))
std::cout << "\e[?25h"; std::cout << "\x1b[?25h";
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment