Skip to content

Prefixing macros in the headers #405

Open
@AKJ7

Description

@AKJ7

No macro in the core headers are prefixed! This leads to macro errors in user-made libraries.

For example, instead of

#define TEST_MODE 2 

in the USBCore.h, something like

#define ARDUINO_TEST_MODE 2

should have been used.

Real life example. I wrote a library with a scope enum like:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions