From d0b356a7ef7439d62501ac575369674cb6f74e4d Mon Sep 17 00:00:00 2001 From: Brumi-2021 <86470699+Brumi-2021@users.noreply.github.com> Date: Sun, 24 Oct 2021 01:59:25 +0200 Subject: [PATCH] Revert "Solving Compile error on gcc10 . Keeping same safety protection about the size of the array ,but with slightly different sintax." This reverts commit f4db4e2b535cd722ce0f5ee6cd8094d4ba717c4f. --- firmware/baseband/spectrum_collector.cpp | 32 +++++++----------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/firmware/baseband/spectrum_collector.cpp b/firmware/baseband/spectrum_collector.cpp index 4256b362a..5d1687b6b 100644 --- a/firmware/baseband/spectrum_collector.cpp +++ b/firmware/baseband/spectrum_collector.cpp @@ -27,7 +27,7 @@ #include "event_m4.hpp" #include "portapack_shared_memory.hpp" -/* #include "event_m4.hpp" that line is duplicated, we can delete it .*/ +#include "event_m4.hpp" #include @@ -105,38 +105,24 @@ void SpectrumCollector::post_message(const buffer_c16_t& data) { } } -/* 3 types of Windowing time domain shapes declaration , but only used Hamming , shapes for FFT - GCC10 compile sintax error c/m (1/2), - The primary diff. between const and constexpr variables is that - the initialization of a const var can be deferred until run time. - A constexpr var. must be initialized at compile time. ... - A var. can be declared with constexpr , when it has a literal type and is initialized. - GCC compile sintax error c/m (2/2) - Static assert --> Tests a software assertion at compile time for debugging. - we keep the same safety compile protection , just changing slightly the sintax checking that the size of the called array is power of 2. - if the bool "constant expression" is TRUE (normal case) , the declaration has no effect. - if the bool "constant expression" is FALSE (abnormal array size) , it is aborted the compile with a msg error. - */ - - -template // Although currently we are not using that Windowing shape, we apply the same GCC10 compile error c/m +template static typename T::value_type spectrum_window_none(const T& s, const size_t i) { - static_assert(power_of_two(sizeof(s)), "Array size must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions. + static_assert(power_of_two(s.size()), "Array size must be power of 2"); return s[i]; }; -template // Currently we are calling and using that Window shape. +template static typename T::value_type spectrum_window_hamming_3(const T& s, const size_t i) { - static_assert(power_of_two(sizeof(s)), "Array size must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions. - const size_t mask = s.size() - 1; // c/m compile error GCC10 , constexpr->const + static_assert(power_of_two(s.size()), "Array size must be power of 2"); + constexpr size_t mask = s.size() - 1; // Three point Hamming window. return s[i] * 0.54f + (s[(i-1) & mask] + s[(i+1) & mask]) * -0.23f; }; -template // Although currently we are not using that Windowing shape, we apply the same GCC10 compile error c/m +template static typename T::value_type spectrum_window_blackman_3(const T& s, const size_t i) { - static_assert(power_of_two(sizeof(s)), "Array size must be power of 2"); // c/m compile error GCC10 , OK for all GCC versions. - const size_t mask = s.size() - 1; // c/m compile error GCC10 , constexpr->const + static_assert(power_of_two(s.size()), "Array size must be power of 2"); + constexpr size_t mask = s.size() - 1; // Three term Blackman window. constexpr float alpha = 0.42f; constexpr float beta = 0.5f * 0.5f;