From 30e5b3fe6b44dfcadae904b73d62042c27775c6f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 27 Aug 2020 13:19:20 +0200 Subject: [PATCH 1/2] Include samd.h instead of sam.h The sam.h file uses some non-portable macros that raise a warning in newer gcc version. This warning was supressed in commit 8575a52 (Add -Wno-expansion-to-defined compile warning flag), but this is not ideal. However, since the only thing sam.h does is figure out what CPU is selected and include the right family header, and we always use SAMD21 CPUs, the only thing sam.h does is include samd.h. So we can easily bypass then and include samd.h directly. This fixes the first part of #556. --- cores/arduino/Arduino.h | 2 +- cores/arduino/SERCOM.h | 2 +- cores/arduino/WVariant.h | 2 +- cores/arduino/cortex_handlers.c | 2 +- cores/arduino/startup.c | 2 +- cores/arduino/wiring_private.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cores/arduino/Arduino.h b/cores/arduino/Arduino.h index 32e99a3e1..8dcd4f0d0 100644 --- a/cores/arduino/Arduino.h +++ b/cores/arduino/Arduino.h @@ -31,7 +31,7 @@ extern "C"{ #endif // __cplusplus // Include Atmel headers -#include "sam.h" +#include #define clockCyclesPerMicrosecond() ( SystemCoreClock / 1000000L ) #define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (SystemCoreClock / 1000L) ) diff --git a/cores/arduino/SERCOM.h b/cores/arduino/SERCOM.h index 6f855af19..cbc3a05de 100644 --- a/cores/arduino/SERCOM.h +++ b/cores/arduino/SERCOM.h @@ -19,7 +19,7 @@ #ifndef _SERCOM_CLASS_ #define _SERCOM_CLASS_ -#include "sam.h" +#include #define SERCOM_FREQ_REF 48000000 #define SERCOM_NVIC_PRIORITY ((1<<__NVIC_PRIO_BITS) - 1) diff --git a/cores/arduino/WVariant.h b/cores/arduino/WVariant.h index bbe2e0c4e..d44a0e2c1 100644 --- a/cores/arduino/WVariant.h +++ b/cores/arduino/WVariant.h @@ -19,7 +19,7 @@ #pragma once #include -#include "sam.h" +#include #ifdef __cplusplus extern "C" { diff --git a/cores/arduino/cortex_handlers.c b/cores/arduino/cortex_handlers.c index a910d0889..e125b6ee8 100644 --- a/cores/arduino/cortex_handlers.c +++ b/cores/arduino/cortex_handlers.c @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include #include #include diff --git a/cores/arduino/startup.c b/cores/arduino/startup.c index d66bfa8e6..3f990abb1 100644 --- a/cores/arduino/startup.c +++ b/cores/arduino/startup.c @@ -16,7 +16,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "sam.h" +#include #include "variant.h" #include diff --git a/cores/arduino/wiring_private.h b/cores/arduino/wiring_private.h index be1babd92..a0fa152cf 100644 --- a/cores/arduino/wiring_private.h +++ b/cores/arduino/wiring_private.h @@ -27,7 +27,7 @@ extern "C" { #endif // Includes Atmel CMSIS -#include "sam.h" +#include int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral ); From 32f7ac6c44d1f181ba761f026d1d05a407c7129b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 27 Aug 2020 13:23:04 +0200 Subject: [PATCH 2/2] Remove -Wno-expansion-to-defined Now that we no longer include sam.h, this warning is no longer triggered in normal builds, so there is no longer a need to supress it. This fixes #556. --- platform.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform.txt b/platform.txt index bdf152186..7c0b73992 100644 --- a/platform.txt +++ b/platform.txt @@ -28,8 +28,8 @@ version=1.8.9 compiler.warning_flags=-w compiler.warning_flags.none=-w compiler.warning_flags.default= -compiler.warning_flags.more=-Wall -Wno-expansion-to-defined -compiler.warning_flags.all=-Wall -Wextra -Wno-expansion-to-defined +compiler.warning_flags.more=-Wall +compiler.warning_flags.all=-Wall -Wextra # EXPERIMENTAL feature: optimization flags # - this is alpha and may be subject to change without notice