Skip to content

Commit

Permalink
Fix some build problems with lambdas in MSVC
Browse files Browse the repository at this point in the history
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 csete#197
  • Loading branch information
daniestevez committed Nov 22, 2020
1 parent 554497b commit 30c02a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions lib/decode_rs_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
12 changes: 8 additions & 4 deletions lib/encode_rs_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 30c02a3

Please sign in to comment.