From 4380d6618fe818aaf0edc6373bdff400338257a8 Mon Sep 17 00:00:00 2001 From: Olivier Date: Wed, 1 Feb 2017 20:45:42 +0100 Subject: [PATCH] Workaround for AVR-specific compiler issue (#759) --- MyConfig.h | 7 +++++++ core/MyIndication.cpp | 12 +++++++++--- core/MyIndication.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/MyConfig.h b/MyConfig.h index 43ab089..fc2eb21 100644 --- a/MyConfig.h +++ b/MyConfig.h @@ -303,6 +303,12 @@ //#define MY_WITH_LEDS_BLINKING_INVERSE +/** +* @def MY_INDICATION_HANDLER +* @brief Enable to use own indication handler +*/ +//#define MY_INDICATION_HANDLER + /********************************************** * Gateway inclusion button/mode configuration @@ -959,4 +965,5 @@ #define MY_LINUX_IS_SERIAL_PTY #define MY_RFM95_ATC_MODE_DISABLED #define MY_RFM95_RST_PIN +#define MY_INDICATION_HANDLER #endif diff --git a/core/MyIndication.cpp b/core/MyIndication.cpp index 72faa22..2a2f69f 100644 --- a/core/MyIndication.cpp +++ b/core/MyIndication.cpp @@ -40,7 +40,13 @@ void setIndication( const indication_t ind ) ledsBlinkErr(ind-INDICATION_ERR_START); } #endif - if (indication) { - indication(ind); - } + indication(ind); } + +#if !defined(MY_INDICATION_HANDLER) +void indication(indication_t) +{ + // empty function, resolves AVR-specific GCC optimization bug (<5.5) if handler not used + // see here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77326 +} +#endif diff --git a/core/MyIndication.h b/core/MyIndication.h index 7d6b7ba..014c35f 100644 --- a/core/MyIndication.h +++ b/core/MyIndication.h @@ -74,6 +74,6 @@ void setIndication( const indication_t ind ); /** * Allow user to define their own indication handler. */ -void indication( const indication_t ) __attribute__((weak)); +void indication( const indication_t ); #endif