Fix for old gcc

This commit is contained in:
Carles Fernandez 2020-06-16 13:04:02 +02:00
parent 771fbf1365
commit 026e0f5c1b
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 25 additions and 2 deletions

View File

@ -74,6 +74,21 @@ if(has_rotl)
)
endif()
if(USE_GENERIC_LAMBDAS)
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)
target_compile_definitions(telemetry_decoder_gr_blocks
PRIVATE
"$<$<COMPILE_FEATURES:cxx_generic_lambdas>:${has_generic_lambdas}>"
"$<$<NOT:$<COMPILE_FEATURES:cxx_generic_lambdas>>:${no_has_generic_lambdas}>"
)
else()
target_compile_definitions(telemetry_decoder_gr_blocks
PRIVATE
-DHAS_GENERIC_LAMBDA=0
)
endif()
if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set_target_properties(telemetry_decoder_gr_blocks

View File

@ -39,8 +39,16 @@ namespace my_rotl = std;
#else
namespace my_rotl
{
auto rotl = [](auto x, auto n) { return (((x) << (n)) ^ ((x) >> (32 - (n)))); }; // Used in the parity check algorithm
}
#ifndef _rotl
#if HAS_GENERIC_LAMBDA
auto rotl = [](auto x, auto n) { return (((x) << (n)) ^ ((x) >> (32 - (n)))); };
#else
#define rotl(X, N) (((X) << (N)) ^ ((X) >> (32 - (N))))
#endif
#else
#define rotl _rotl
#endif
} // namespace my_rotl
#endif