-
-
Notifications
You must be signed in to change notification settings - Fork 725
Fix warnings and remove -Wno-expansion-to-defined #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
matthijskooijman
referenced
this issue
in adafruit/ArduinoCore-samd
Aug 27, 2020
matthijskooijman
added a commit
to matthijskooijman/ArduinoCore-samd
that referenced
this issue
Aug 27, 2020
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 arduino#556.
matthijskooijman
added a commit
to matthijskooijman/ArduinoCore-samd
that referenced
this issue
Aug 27, 2020
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 arduino#556.
This was referenced Aug 27, 2020
matthijskooijman
added a commit
to matthijskooijman/ArduinoCore-samd
that referenced
this issue
Nov 26, 2020
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 arduino#556.
matthijskooijman
added a commit
to matthijskooijman/ArduinoCore-samd
that referenced
this issue
Nov 26, 2020
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 arduino#556.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In commit 8575a52, the -Wno-expansion-to-defined was introduced, apparently to prevent a ton of warnings generated by the Atmel CMSIS header files (initially reported here: #290 (comment)):
I just tested without this flag (SAMD core 1.8.8, with CMSIS 1.2.0), and it seems the warnings are still there.
Since this warning does point to actual non-portable code, it would be nicer if it was not suppressed, but fixed in the CMSIS instead.
The actual problem seems to be that they use a macro that contains
defined()
, e.g. something like#define BAR defined(FOO)
and then check that later (#if BAR
). In the Atmel CMSIS code, this is a bit more complex, because they use apart_is_defined
intermediate macro: https://github.com/arduino/ArduinoModule-CMSIS-Atmel/blob/46ab1021146152a64caf1ddbb837d8181b8faa35/CMSIS-Atmel/CMSIS/Device/ATMEL/sam.h#L32E.g.:
I think the portable way to write this, is to write:
This might also need an else to define it as 0, but that's not needed if the macro is only used from the preprocessor I think. There's 150 instances of this macro, but all in the same file, so might be fixable automatically.
I also looked to see if newer versions of the Atmel CMSIS library still have this, but couldn't quite find this particular library with this layout. I looked inside the "ASF standalone framework 3.48", but that seemingly contains the same header files and components, but there is no "sam.h" that figures out what header file to include, only e.g. "samd21.h" that figures out which of the SAMD21 headers to include. To use those, I think we should let our own headers decide which family header to include exactly. I also looked at the Microchips packs, which is pretty much the same thing, but downloadable per family.
So if we'd upgrade this CMSIS stuff, I guess we could just pick out the families we need and include the right one directly.
Thinking on this, we could even do that now already and bypass the problematic
sam.h
header entirely. Looking at boards.txt, all supported boards are SAMD21 anyway, so the below diff actually fixes this warning right now (while I was there, I also replaced the""
with<>
in the includes, which is not actualy needed for this fix, but is a bit more correct):The text was updated successfully, but these errors were encountered: