Skip to content

Commit

Permalink
Warning-free build on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Oct 11, 2023
1 parent c95fc45 commit 22f3afe
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion include/kfr/base/basic_expressions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ struct expression_linspace
T invsize;

expression_linspace(T start, T stop, size_t size, bool endpoint = false)
: start(start), stop(stop), size(size), invsize(1.0 / T(endpoint ? size - 1 : size))
: start(start), stop(stop), size(size), invsize(T(1.0) / T(endpoint ? size - 1 : size))
{
}

Expand Down
2 changes: 1 addition & 1 deletion include/kfr/base/reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ struct histogram_data
KFR_MEM_INTRINSIC void put(T value)
{
const T x = 1 + value * size();
++m_values[std::floor(clamp(x, 0, size() + 1))];
++m_values[static_cast<uint64_t>(std::floor(clamp(x, 0, size() + 1)))];
}

private:
Expand Down
4 changes: 2 additions & 2 deletions include/kfr/base/shape.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ KFR_INTRINSIC bool compare_indices(const shape<dims>& indices, const shape<dims>
index_t dim = dims - 1)
{
CMT_LOOP_UNROLL
for (int i = dim; i >= 0; --i)
for (int i = static_cast<int>(dim); i >= 0; --i)
{
if (CMT_UNLIKELY(indices[i] >= stop[i]))
return false;
Expand All @@ -685,7 +685,7 @@ KFR_INTRINSIC bool increment_indices(shape<dims>& indices, const shape<dims>& st
{
indices[dim] += 1;
CMT_LOOP_UNROLL
for (int i = dim; i >= 0;)
for (int i = static_cast<int>(dim); i >= 0;)
{
if (CMT_LIKELY(indices[i] < stop[i]))
return true;
Expand Down
4 changes: 2 additions & 2 deletions include/kfr/cometa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,11 @@ struct cvalseq_impl<T, 0, Nstart, Nstep> : cvals_t<T>
{
};
template <typename T, T Nstart, ptrdiff_t Nstep>
struct cvalseq_impl<T, 1, Nstart, Nstep> : cvals_t<T, static_cast<T>(Nstart)>
struct cvalseq_impl<T, 1, Nstart, Nstep> : cvals_t<T, Nstart>
{
};
template <typename T, T Nstart, ptrdiff_t Nstep>
struct cvalseq_impl<T, 2, Nstart, Nstep> : cvals_t<T, static_cast<T>(Nstart), static_cast<T>(Nstart + Nstep)>
struct cvalseq_impl<T, 2, Nstart, Nstep> : cvals_t<T, Nstart, static_cast<T>(Nstart + Nstep)>
{
};

Expand Down
2 changes: 1 addition & 1 deletion include/kfr/dsp/ebu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ struct ebu_channel
break;
case Speaker::LeftSurround:
case Speaker::RightSurround:
m_output_energy_gain = dB_to_power(+1.5);
m_output_energy_gain = static_cast<T>(dB_to_power(+1.5));
break;
default:
break;
Expand Down
5 changes: 5 additions & 0 deletions include/kfr/dsp/fir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include "../base/univector.hpp"
#include "../simd/vec.hpp"

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -323,3 +326,5 @@ KFR_FUNCTION filter<U>* make_fir_filter(cpu_t cpu, const univector_ref<const T>&
}
#endif
} // namespace kfr

CMT_PRAGMA_MSVC(warning(pop))
5 changes: 5 additions & 0 deletions include/kfr/graphics/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

#include "impl/scaled.hpp"

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{

Expand Down Expand Up @@ -405,3 +408,5 @@ struct representation<kfr::color<T>>
}
};
} // namespace cometa

CMT_PRAGMA_MSVC(warning(pop))
2 changes: 1 addition & 1 deletion include/kfr/io/python_plot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void python(const std::string& name, const std::string& code)
std::string filename;
{
char curdir[1024];
(void)cross_getcwd(curdir, arraysize(curdir));
(void)cross_getcwd(curdir, (int)arraysize(curdir));
filename = curdir;
}
#ifdef CMT_OS_WIN
Expand Down
6 changes: 3 additions & 3 deletions include/kfr/math/impl/gamma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace intrinsics
{
template <typename T>
constexpr T gamma_precalc[] = {
0x2.81b263fec4e08p+0, 0x3.07b4100e04448p+16, -0xa.a0da01d4d4e2p+16, 0xf.05ccb27bb9dbp+16,
-0xa.fa79616b7c6ep+16, 0x4.6dd6c10d4df5p+16, -0xf.a2304199eb4ap+12, 0x1.c21dd4aade3dp+12,
-0x1.62f981f01cf84p+8, 0x5.a937aa5c48d98p+0, -0x3.c640bf82e2104p-8, 0xc.914c540f959cp-24,
T(0x2.81b263fec4e08p+0), T(0x3.07b4100e04448p+16), T(-0xa.a0da01d4d4e2p+16), T(0xf.05ccb27bb9dbp+16),
T(-0xa.fa79616b7c6ep+16), T(0x4.6dd6c10d4df5p+16), T(-0xf.a2304199eb4ap+12), T(0x1.c21dd4aade3dp+12),
T(-0x1.62f981f01cf84p+8), T(0x5.a937aa5c48d98p+0), T(-0x3.c640bf82e2104p-8), T(0xc.914c540f959cp-24),
};

template <typename T, size_t N>
Expand Down
4 changes: 1 addition & 3 deletions include/kfr/simd/impl/backend_generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ KFR_INTRINSIC simd<double, 2> simd_vec_shuffle(simd_t<double, 2>, const simd<dou
template <uint8_t max>
KFR_INTRINSIC constexpr uint8_t vec_idx(size_t value)
{
return value >= max ? 0 : value;
return value >= static_cast<size_t>(max) ? 0 : static_cast<uint8_t>(value);
}

#ifdef CMT_ARCH_AVX512
Expand Down Expand Up @@ -1827,8 +1827,6 @@ KFR_INTRINSIC simd<T, Nout> universal_shuffle(simd_t<T, Nin>, const simd<T, Nin>
{
using Indices = csizes_t<indices...>;

constexpr bool floating = typeclass<T> == datatype::f;

constexpr size_t minwidth = minimum_vector_width<T>;
constexpr size_t maxwidth = vector_width<T>;
constexpr size_t minindex = cminof(Indices{});
Expand Down
5 changes: 5 additions & 0 deletions include/kfr/simd/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include <algorithm>
#include <utility>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -659,3 +662,5 @@ KFR_I_CE vec<bit<T>, N>::vec(const base& v) CMT_NOEXCEPT

} // namespace CMT_ARCH_NAME
} // namespace kfr

CMT_PRAGMA_MSVC(warning(pop))
3 changes: 2 additions & 1 deletion include/kfr/simd/shuffle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 5051))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
Expand Down Expand Up @@ -244,7 +245,7 @@ KFR_INTRINSIC vec<T, count> concat_and_slice(const vec<T, N1>& x, const vec<T, N
template <size_t start, size_t count, typename T, size_t N1, size_t N2, KFR_ENABLE_IF(N1 < N2)>
KFR_INTRINSIC vec<T, count> concat_and_slice(const vec<T, N1>& x, const vec<T, N2>& y)
{
return x.shuffle(csizeseq<N2, -(N2 - N1)>)
return x.shuffle(csizeseq<N2, N1 - N2>)
.shuffle(y, csizeseq<N2 * 2>)
.shuffle(csizeseq<count, N2 - N1 + start>);
}
Expand Down
1 change: 1 addition & 0 deletions include/kfr/simd/vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ CMT_PRAGMA_GNU(GCC diagnostic ignored "-Wpacked")

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4814))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
Expand Down
1 change: 1 addition & 0 deletions tests/unit/base/tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 5051))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/dsp/biquad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <kfr/dsp/biquad_design.hpp>
#include <kfr/dsp/special.hpp>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4305))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -111,3 +114,5 @@ TEST(biquad_lowpass2)
}
} // namespace CMT_ARCH_NAME
} // namespace kfr

CMT_PRAGMA_MSVC(warning(pop))
5 changes: 5 additions & 0 deletions tests/unit/dsp/ebu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <kfr/dsp/ebu.hpp>
#include <kfr/dsp/oscillators.hpp>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4244))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -268,3 +271,5 @@ TEST(ebu_lra_1_2_3_and_4)
} // namespace CMT_ARCH_NAME

} // namespace kfr

CMT_PRAGMA_MSVC(warning(pop))
5 changes: 5 additions & 0 deletions tests/unit/simd/abs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include <kfr/io.hpp>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4146))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand All @@ -20,3 +23,5 @@ TEST(abs)
}
} // namespace CMT_ARCH_NAME
} // namespace kfr

CMT_PRAGMA_MSVC(warning(pop))
6 changes: 6 additions & 0 deletions tests/unit/simd/min_max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#include <kfr/io.hpp>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4146))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -68,3 +71,6 @@ TEST(absmax)
}
} // namespace CMT_ARCH_NAME
} // namespace kfr


CMT_PRAGMA_MSVC(warning(pop))
6 changes: 6 additions & 0 deletions tests/unit/simd/operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <kfr/simd/horizontal.hpp>
#include <kfr/simd/operators.hpp>

CMT_PRAGMA_MSVC(warning(push))
CMT_PRAGMA_MSVC(warning(disable : 4146))

namespace kfr
{
inline namespace CMT_ARCH_NAME
Expand Down Expand Up @@ -268,3 +271,6 @@ TEST(apply)
}
} // namespace CMT_ARCH_NAME
} // namespace kfr


CMT_PRAGMA_MSVC(warning(pop))
2 changes: 1 addition & 1 deletion tools/sample_rate_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char** argv)

// Initialize WAV reader and get file sample rate
audio_reader_wav<double> reader(open_file_for_reading(argv[1]));
const size_t input_sr = reader.format().samplerate;
const size_t input_sr = static_cast<size_t>(reader.format().samplerate);

// Read channels of audio
univector2d<double> input_channels = reader.read_channels(reader.format().length);
Expand Down

0 comments on commit 22f3afe

Please sign in to comment.