From 4363dfcc9fecb8cd2f4e1af14e5e074a8d283057 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 16 Nov 2019 19:21:02 +0100 Subject: [PATCH] Fix for old compilers --- src/algorithms/libs/CMakeLists.txt | 24 ++++++ src/algorithms/libs/item_type_helpers.cc | 105 +++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index fda9d666e..849809289 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -135,6 +135,30 @@ target_compile_definitions(algorithms_libs PUBLIC -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" ) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") + target_compile_definitions(algorithms_libs + PRIVATE -DOLDCOMPILER=1 + ) + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if(CLANG_VERSION VERSION_LESS "600") + target_compile_definitions(algorithms_libs + PRIVATE -DOLDCOMPILER=1 + ) + endif() + else() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") + target_compile_definitions(algorithms_libs + PRIVATE -DOLDCOMPILER=1 + ) + endif() + endif() +endif() + set_property(TARGET algorithms_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ diff --git a/src/algorithms/libs/item_type_helpers.cc b/src/algorithms/libs/item_type_helpers.cc index 8359407b3..811b9362e 100644 --- a/src/algorithms/libs/item_type_helpers.cc +++ b/src/algorithms/libs/item_type_helpers.cc @@ -188,18 +188,33 @@ item_type_converter_t make_vector_converter(const std::string &input_type, if (input_type == output_type) { size_t input_size = item_type_size(input_type); +#ifdef OLDCOMPILER + return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, input_size); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return copy_converter(arg1, arg2, arg3, input_size); }; +#endif } if (input_type == "byte") { if (output_type == "short") { +#ifdef OLDCOMPILER + return std::bind(convert_8i_16i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3);_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8i_16i(arg1, arg2, arg3); }; +#endif } else if (output_type == "float") { +#ifdef OLDCOMPILER + return std::bind(convert_8i_32f, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8i_32f(arg1, arg2, arg3); }; +#endif } } else if (input_type == "cbyte") @@ -207,15 +222,30 @@ item_type_converter_t make_vector_converter(const std::string &input_type, if (output_type == "ibyte") { size_t input_size = item_type_size(input_type); +#ifdef OLDCOMPILER + return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, input_size); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return copy_converter(arg1, arg2, arg3, input_size); }; +#endif } if (output_type == "cshort" or output_type == "ishort") { +#ifdef OLDCOMPILER +return std::bind(convert_8ic_16ic, std::placeholders::_1, + std::placeholders::_2, std::placehold +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8ic_16ic(arg1, arg2, arg3); }; +#endif } else if (output_type == "gr_complex") { +#ifdef OLDCOMPILER + return std::bind(convert_8ic_32fc, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8ic_32fc(arg1, arg2, arg3); }; +#endif } } else if (input_type == "ibyte") @@ -223,80 +253,155 @@ item_type_converter_t make_vector_converter(const std::string &input_type, if (output_type == "cbyte") { size_t input_size = item_type_size(input_type); +#ifdef OLDCOMPILER + return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, input_size); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return copy_converter(arg1, arg2, arg3, input_size); }; +#endif } else if (output_type == "cshort" or output_type == "ishort") { +#ifdef OLDCOMPILER + return std::bind(convert_8i_16i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8i_16i(arg1, arg2, arg3); }; +#endif } else if (output_type == "gr_complex") { +#ifdef OLDCOMPILER + return std::bind(convert_8i_32f, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_8i_32f(arg1, arg2, arg3); }; +#endif } } else if (input_type == "short") { if (output_type == "byte") { +#ifdef OLDCOMPILER + return std::bind(convert_16i_8i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16i_8i(arg1, arg2, arg3); }; +#endif } else if (output_type == "float") { +#ifdef OLDCOMPILER + return std::bind(convert_16i_32f, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16i_32f(arg1, arg2, arg3); }; +#endif } } else if (input_type == "cshort") { if (output_type == "cbyte" or output_type == "ibyte") { +#ifdef OLDCOMPILER + return std::bind(convert_16ic_8ic, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16ic_8ic(arg1, arg2, arg3); }; +#endif } if (output_type == "ishort") { size_t input_size = item_type_size(input_type); +#ifdef OLDCOMPILER + return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, input_size); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return copy_converter(arg1, arg2, arg3, input_size); }; +#endif } else if (output_type == "gr_complex") { +#ifdef OLDCOMPILER + return std::bind(convert_16ic_32fc, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16ic_32fc(arg1, arg2, arg3); }; +#endif } } else if (input_type == "ishort") { if (output_type == "cbyte" or output_type == "ibyte") { +#ifdef OLDCOMPILER + return std::bind(convert_16i_8i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16i_8i(arg1, arg2, arg3); }; +#endif } if (output_type == "cshort") { size_t input_size = item_type_size(input_type); +#ifdef OLDCOMPILER + return std::bind(copy_converter, std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, input_size); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return copy_converter(arg1, arg2, arg3, input_size); }; +#endif } else if (output_type == "gr_complex") { +#ifdef OLDCOMPILER + return std::bind(convert_16i_32f, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_16i_32f(arg1, arg2, arg3); }; +#endif } } else if (input_type == "float") { if (output_type == "byte") { +#ifdef OLDCOMPILER + return std::bind(convert_32f_8i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_32f_8i(arg1, arg2, arg3); }; +#endif } else if (output_type == "short") { +#ifdef OLDCOMPILER + return std::bind(convert_32f_16i, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_32f_16i(arg1, arg2, arg3); }; +#endif } } else if (input_type == "gr_complex") { if (output_type == "cbyte" or output_type == "ibyte") { +#ifdef OLDCOMPILER + return std::bind(convert_32fc_8ic, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_32fc_8ic(arg1, arg2, arg3); }; +#endif } else if (output_type == "cshort" or output_type == "ishort") { +#ifdef OLDCOMPILER + return std::bind(convert_32fc_16ic, std::placeholders::_1, + std::placeholders::_2, std::placeholders::_3); +#else return [=](auto &&arg1, auto &&arg2, auto &&arg3) { return convert_32fc_16ic(arg1, arg2, arg3); }; +#endif } }