From 634e777cfd3e595cf46d006f15f9bab59cd4a2b1 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 9 Sep 2022 20:21:03 +0200 Subject: [PATCH] fixed compilation issues on linux --- CMakeLists.txt | 4 ++-- src/currency_core/currency_format_utils.cpp | 10 ++++++++-- src/currency_core/currency_format_utils_abstract.h | 14 ++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e62038f5..0f55455d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,14 +137,14 @@ else() endif() set(C_WARNINGS "-Waggregate-return -Wnested-externs -Wstrict-prototypes") set(CXX_WARNINGS "-Wno-reorder -Wno-missing-field-initializers") - try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/utils/test-static-assert.c" COMPILE_DEFINITIONS "-std=c11") + try_compile(STATIC_ASSERT_RES "${CMAKE_CURRENT_BINARY_DIR}/static-assert" "${CMAKE_CURRENT_SOURCE_DIR}/utils/test-static-assert.c" COMPILE_DEFINITIONS "-std=c++14") if(STATIC_ASSERT_RES) set(STATIC_ASSERT_FLAG "") else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -ftemplate-depth-1024 -std=c++14 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") if (NOT APPLE AND NOT MSVC) if (CLANG) set(LLVM_USE_LINKER "gold") diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 54932aa3..d31e04b4 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -606,10 +606,16 @@ namespace currency // tx.version > TRANSACTION_VERSION_PRE_HF4 // all amounts are hidden with Pedersen commitments // therefore fee should be explicitly stated in the extra - if (!process_type_in_variant_container(tx.extra, [&](const zarcanum_tx_data_v1& ztd) -> bool { + auto cb = [&](const zarcanum_tx_data_v1& ztd) -> bool { fee += ztd.fee; return true; // continue - }, false)) + }; + + + bool r = process_type_in_variant_container(tx.extra, cb, false); + + + if (!r) { fee = 0; return false; diff --git a/src/currency_core/currency_format_utils_abstract.h b/src/currency_core/currency_format_utils_abstract.h index adddd8e5..addfd80a 100644 --- a/src/currency_core/currency_format_utils_abstract.h +++ b/src/currency_core/currency_format_utils_abstract.h @@ -109,7 +109,7 @@ namespace currency //--------------------------------------------------------------- // if cb returns true, it means "continue", false -- means "stop" template - bool process_type_in_variant_container(variant_container_t& av, callback_t& cb, bool return_value_if_none_found = true) + bool process_type_in_variant_container(const variant_container_t& av, callback_t& cb, bool return_value_if_none_found = true) { bool found = false; for (auto& ai : av) @@ -189,19 +189,19 @@ namespace currency } //, txin_htlc, txin_zc_input - inline bool compare_variant_by_types(const txin_multisig& left, typename txin_multisig& right) + inline bool compare_variant_by_types(const txin_multisig& left, const txin_multisig& right) { return (left.multisig_out_id < right.multisig_out_id); } //--------------------------------------------------------------- - inline bool compare_variant_by_types(const txin_gen& left, typename txin_gen& right) + inline bool compare_variant_by_types(const txin_gen& left, const txin_gen& right) { //actually this should never happen, should we leave it in case it happen in unit tests? @sowle return (left.height < right.height); } //--------------------------------------------------------------- template - bool compare_variant_by_types(const type_with_kimage_t& left, typename type_with_kimage_t& right) + bool compare_variant_by_types(const type_with_kimage_t& left, const type_with_kimage_t& right) { return (left.k_image < right.k_image); } @@ -213,8 +213,10 @@ namespace currency { ASSERT_MES_AND_THROW("[compare_varian_by_types] Left and Right types matched type " << typeid(t_type_left).name()); } - //@sowle should we use here variant index instead? (tags takes since it's ids something more "unchangebale", but we can reconsider) - return (variant_serialization_traits, typename t_type_left>::get_tag() < variant_serialization_traits, typename t_type_right>::get_tag()); + typedef binary_archive bin_archive; + typedef variant_serialization_traits traits_left; + typedef variant_serialization_traits traits_right; + return (traits_left::get_tag() < traits_right::get_tag()); } //--------------------------------------------------------------- template