fixed compilation issues on linux

This commit is contained in:
cryptozoidberg 2022-09-09 20:21:03 +02:00
parent 41308d86a6
commit 634e777cfd
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 18 additions and 10 deletions

View file

@ -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")

View file

@ -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<zarcanum_tx_data_v1>(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<zarcanum_tx_data_v1>(tx.extra, cb, false);
if (!r)
{
fee = 0;
return false;

View file

@ -109,7 +109,7 @@ namespace currency
//---------------------------------------------------------------
// if cb returns true, it means "continue", false -- means "stop"
template<typename specific_type_t, typename variant_container_t, typename callback_t>
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<typename type_with_kimage_t>
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 binary_archive<true>, typename t_type_left>::get_tag() < variant_serialization_traits<typename binary_archive<true>, typename t_type_right>::get_tag());
typedef binary_archive<true> bin_archive;
typedef variant_serialization_traits<bin_archive, t_type_left> traits_left;
typedef variant_serialization_traits<bin_archive, t_type_right> traits_right;
return (traits_left::get_tag() < traits_right::get_tag());
}
//---------------------------------------------------------------
template<typename t_type_left>