diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c9ba26..c602f9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,15 @@ set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) # define explicitely GCC version to prevent redefintion by CLANG -# if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -# add_compile_options(-fgnuc-version=${CMAKE_CXX_COMPILER_VERSION}) -# endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # add_compile_options(-fgnuc-version=${CMAKE_CXX_COMPILER_VERSION}) + string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) + list(GET VERSION_LIST 0 VER_MAJOR) + list(GET VERSION_LIST 1 VER_MINOR) + list(GET VERSION_LIST 2 VER_PATCH) + math(EXPR GCC_VER "${VER_MAJOR}*10000+${VER_MINOR}*100+${VER_PATCH}") + add_compile_definitions("GCC_VERSION=${GCC_VER}") +endif() # for ccls set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/asibfm700_config.h b/asibfm700_config.h index 9c1f3bd..300afe1 100644 --- a/asibfm700_config.h +++ b/asibfm700_config.h @@ -450,18 +450,26 @@ public: std::error_code ec{}; std::string output_buffer; - // #ifdef __GNUG__ - // #if __GNUG__ < 16 - // auto write_rec = [&output_buffer, &ec, obj_ptr = this](this auto& self) -> void { - // #else +#ifdef __GNUG__ +// to fix GCC compilation crash for the versions < 16 +#if GCC_VERSION < 160000 + auto write_rec = [&output_buffer, &ec, obj_ptr = this](this auto& self) -> void { +#else auto write_rec = [&output_buffer, &ec, this](this auto& self) -> void { - // #endif - // #endif +#endif +#endif if constexpr (I < NUMBER_OF_RECORDS) { // add an empty string within records std::format_to(std::back_inserter(output_buffer), "{}", DEFAULT_RECORD_DELIMITER); +#ifdef __GNUG__ +// to fix GCC compilation crash for the versions < 16 +#if GCC_VERSION < 160000 + ec = obj_ptr->template formatRecord(output_buffer, DEFAULT_RECORD_DELIMITER, true); +#else ec = formatRecord(output_buffer, DEFAULT_RECORD_DELIMITER, true); +#endif +#endif if (ec) { return; }