From 2cb29ab67348f3a709697843a9d391f8a307410e Mon Sep 17 00:00:00 2001 From: KLASSENTS Date: Wed, 28 May 2025 12:55:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D1=8F=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - исправление выявленных ошибок - если используется не-void функция без return, появляется ошибка вместо предупреждения Co-authored-by: KLASSENTS Co-committed-by: KLASSENTS --- cores/arduino/wiring_constants.h | 30 ++++++++++++++---------------- libraries/EEPROM/src/EEPROM.h | 2 +- platform.txt | 4 ++-- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/cores/arduino/wiring_constants.h b/cores/arduino/wiring_constants.h index 1231a2f..f46dc93 100644 --- a/cores/arduino/wiring_constants.h +++ b/cores/arduino/wiring_constants.h @@ -56,25 +56,23 @@ enum BitOrder #define NOT_AN_INTERRUPT -1 // Math -#ifdef __cplusplus - #include - using std::min; - using std::max; -#else // C - #include - #ifndef abs - #define abs(x) ((x)>0?(x):-(x)) - #endif // abs +#include +// undefine stdlib's abs if encountered +#ifdef abs +#undef abs +#endif +#ifndef abs + #define abs(x) ((x)>0?(x):-(x)) +#endif // abs - #ifndef min - #define min(a,b) ((a)<(b)?(a):(b)) - #endif // min +#ifndef min + #define min(a,b) ((a)<(b)?(a):(b)) +#endif // min - #ifndef max - #define max(a,b) ((a)>(b)?(a):(b)) - #endif // max +#ifndef max + #define max(a,b) ((a)>(b)?(a):(b)) +#endif // max -#endif // __cplusplus #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) diff --git a/libraries/EEPROM/src/EEPROM.h b/libraries/EEPROM/src/EEPROM.h index 315c4e0..780a89e 100644 --- a/libraries/EEPROM/src/EEPROM.h +++ b/libraries/EEPROM/src/EEPROM.h @@ -94,7 +94,7 @@ struct EEPROMClass{ uint16_t length() { return (uint16_t)EEPROM_LENGHT; } template< typename T > - T &put(int idx, T &data) + const T &put(int idx, const T &data) { void* dataPointer = (void*)&data; // check if idx is valid diff --git a/platform.txt b/platform.txt index 2392730..2920a9b 100644 --- a/platform.txt +++ b/platform.txt @@ -34,8 +34,8 @@ compiler.optimization_flags.debug=-Og -g3 compiler.extra_flags = -march=rv32imc_zicsr_zifencei -mabi=ilp32 -mcmodel=medlow -Wall -fsigned-char -ffunction-sections compiler.S.flags = {compiler.extra_flags} -x assembler-with-cpp {compiler.define} -I"{runtime.platform.path}/libraries/FreeRTOS/src" {compiler.optimization_flags} {compiler.warning_flags} {compiler.MIK32_Amur.extra_include} -compiler.c.flags = -c -std=gnu11 {compiler.extra_flags} {compiler.define} {compiler.warning_flags} {compiler.optimization_flags} {compiler.MIK32_Amur.extra_include} -compiler.cpp.flags = -c -std=gnu++17 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics {compiler.extra_flags} {compiler.define} {compiler.warning_flags} {compiler.optimization_flags} {compiler.MIK32_Amur.extra_include} +compiler.c.flags = -c -std=gnu11 -Werror=return-type {compiler.extra_flags} {compiler.define} {compiler.warning_flags} {compiler.optimization_flags} {compiler.MIK32_Amur.extra_include} +compiler.cpp.flags = -c -std=gnu++17 -fabi-version=0 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics -Werror=return-type {compiler.extra_flags} {compiler.define} {compiler.warning_flags} {compiler.optimization_flags} {compiler.MIK32_Amur.extra_include} compiler.c.elf.flags = -march=rv32imc_zicsr_zifencei -mabi=ilp32 -mcmodel=medlow -nostartfiles -Xlinker compiler.ar.flags=rc compiler.elf2bin.flags=-O binary