Skip to content

Duplicate defines when using CMSIS headers #2451

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

Open
Hexxeh opened this issue May 2, 2025 · 5 comments
Open

Duplicate defines when using CMSIS headers #2451

Hexxeh opened this issue May 2, 2025 · 5 comments
Assignees
Milestone

Comments

@Hexxeh
Copy link

Hexxeh commented May 2, 2025

Within https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/cmsis/stub/CMSIS/Device/RP2350/Source/system_RP2350.c I see there's includes for both RP2350.h and hardware/clocks.h. hardware/clocks.h includes the following chain of headers: pico.h -> pico/platform.h -> hardware/regs/addressmap.h. This last file seems to duplicate many defines from RP2350.h.

How are are the CMSIS headers intended to be used without causing duplicate defines?

@kilograham kilograham added this to the 2.1.2 milestone May 2, 2025
@kilograham kilograham self-assigned this May 2, 2025
@kilograham kilograham modified the milestones: 2.1.2, 2.2.0 May 2, 2025
@kilograham
Copy link
Contributor

GCC does not complain at standard warning levels as the values are somewhat the same (signed vs unsigned) - arguably this is a bit surprising, but meant that our simple compilation sanity checks pass. pico-examples builds with more warnings, but evidently does not use CMSIS anywhere

@kilograham kilograham modified the milestones: 2.1.2, 2.2.0 May 4, 2025
@kilograham
Copy link
Contributor

ok, it seems that GCC does not complain as these are system headers (are you using the normal cmake build system?, or a particular compiler version?) - or

you can make the build fail by passing -Wsystem-headersor indeed pass by -Wno-system-headers which is the default.

We can remove the duplicates in 2.2.0 but not doing so now as there are other compilation issues with -Wsystem-headers

@Hexxeh
Copy link
Author

Hexxeh commented May 6, 2025

I'm not using CMake (because the project I'm trying to add support to doesn't use it, it uses waf), and I'm using the ARM provided toolchain from here: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads (version 14.2.1).

I'll give -Wno-system-headers a try, we're not setting -Wsystem-headers based on a quick grep, but there are probably other oddities about this build system.

@kilograham
Copy link
Contributor

to be clear, the CMake build adds the SDK headers (including the CMSIS ones) to the system include path - that is probably the facet that is missing from your build. see for example #82

@Hexxeh
Copy link
Author

Hexxeh commented May 6, 2025

Ah, yes, that's probably the issue. I think we're just specifying everything with -I. I will try to rejig the build to use -isystem. Thank you!

mjs1441 pushed a commit to mjs1441/betaflight that referenced this issue May 13, 2025
Add directories in $(SYS_INCLUDE_DIRS) to the search path via -isystem.

This allows a workaround for raspberrypi/pico-sdk#2451 by
using system headers, which are more tolerant of macro redefinitions.
mjs1441 pushed a commit to mjs1441/betaflight that referenced this issue May 14, 2025
Add directories in $(SYS_INCLUDE_DIRS) to the search path via -isystem.

This allows a workaround for raspberrypi/pico-sdk#2451 by
using system headers, which are more tolerant of macro redefinitions.
mjs1441 pushed a commit to mjs1441/betaflight that referenced this issue May 15, 2025
Add directories in $(SYS_INCLUDE_DIRS) to the search path via -isystem.

This allows a workaround for raspberrypi/pico-sdk#2451 by
using system headers, which are more tolerant of macro redefinitions.
blckmn pushed a commit to betaflight/betaflight that referenced this issue May 15, 2025
Add directories in $(SYS_INCLUDE_DIRS) to the search path via -isystem.

This allows a workaround for raspberrypi/pico-sdk#2451 by
using system headers, which are more tolerant of macro redefinitions.

Co-authored-by: Matthew Selby <matthewjselby@aol.com>
cvetaevvitaliy pushed a commit to cvetaevvitaliy/betaflight that referenced this issue May 27, 2025
Add directories in $(SYS_INCLUDE_DIRS) to the search path via -isystem.

This allows a workaround for raspberrypi/pico-sdk#2451 by
using system headers, which are more tolerant of macro redefinitions.

Co-authored-by: Matthew Selby <matthewjselby@aol.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants