From 30c02a313ebf71209b8d1633e2c9b417e684f74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Est=C3=A9vez?= Date: Sun, 22 Nov 2020 11:35:16 +0100 Subject: [PATCH] Fix some build problems with lambdas in MSVC One of the problems is caused by a ternary operator having different lambdas in the "if" and "else" clauses. This gives some problem regarding type conversion. The ternary operator has been replaced by an if/else construct. The other problem regards a constexpr variable that is not captured. The constexpr variable has been set to static constexpr. This closes #197 --- lib/decode_rs_impl.cc | 8 +++++--- lib/encode_rs_impl.cc | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/decode_rs_impl.cc b/lib/decode_rs_impl.cc index 7cab6b98..6eee8992 100644 --- a/lib/decode_rs_impl.cc +++ b/lib/decode_rs_impl.cc @@ -46,9 +46,11 @@ decode_rs_impl::decode_rs_impl(bool dual_basis, int interleave) "decode_rs", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), d_interleave(interleave) { - d_decode_rs = dual_basis - ? [](uint8_t* data) { return decode_rs_ccsds(data, NULL, 0, 0); } - : [](uint8_t* data) { return decode_rs_8(data, NULL, 0, 0); }; + if (dual_basis) { + d_decode_rs = [](uint8_t* data) { return decode_rs_ccsds(data, NULL, 0, 0); }; + } else { + d_decode_rs = [](uint8_t* data) { return decode_rs_8(data, NULL, 0, 0); }; + } d_rs_codeword.resize(d_ccsds_nn); d_nroots = d_ccsds_nroots; diff --git a/lib/encode_rs_impl.cc b/lib/encode_rs_impl.cc index c5e0af34..4484d535 100644 --- a/lib/encode_rs_impl.cc +++ b/lib/encode_rs_impl.cc @@ -48,10 +48,14 @@ encode_rs_impl::encode_rs_impl(bool dual_basis, int interleave) "encode_rs", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), d_interleave(interleave) { - constexpr int parity_offset = d_ccsds_nn - d_ccsds_nroots; - d_encode_rs = - dual_basis ? [](uint8_t* data) { encode_rs_ccsds(data, &data[parity_offset], 0); } - : [](uint8_t* data) { encode_rs_8(data, &data[parity_offset], 0); }; + static constexpr int parity_offset = d_ccsds_nn - d_ccsds_nroots; + if (dual_basis) { + d_encode_rs = [](uint8_t* data) { + encode_rs_ccsds(data, &data[parity_offset], 0); + }; + } else { + d_encode_rs = [](uint8_t* data) { encode_rs_8(data, &data[parity_offset], 0); }; + } d_rs_codeword.resize(d_ccsds_nn); d_nroots = d_ccsds_nroots;