arduino / arduino/ArduinoCore-avr
Add "namespace" prefixes to macro definitions in headers to avoid collisions
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
No macro in the core headers are prefixed! This leads to macro errors in user-made libraries.
For example, instead of
``` c++
#define TEST_MODE 2
```
in the USBCore.h, something like
``` c++
#define ARDUINO_TEST_MODE 2
```
should have been used.
Real life example. I wrote a library with a scope enum like:
``` c++
enum class Test
{
TEST_MODE = 0x80
}
```
`TEST_MODE` is the name of the variable as defined in the documentations of the device that needed programming.
No errors were reported from the GCC Compiler on other Arduino except on the Nano, which supports the USB. The USBCore.h header gets included automatically overlapping the `#define TEST_MODE 2` as mentioned before with the `enum TEST_MODE`.
Prefixing macros and types are considered good practices, and should be a required considering the number of user-made libraries that the Arduino has.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with USBCore.h and inspect the other core headers for unprefixed macro definitions like TEST_MODE. Trace which headers are included automatically on USB-capable boards, then determine the full set of definitions that need consistent prefixes. Done means user-defined names such as TEST_MODE no longer collide with core macros.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100