Skip to content

Naming conventions for member enums #7

@ppescher

Description

@ppescher

The library forces you to write code like this (verbose):
rtc.setClockSource(STM32RTC::RTC_LSE_CLOCK);
Or this (shorter, but still redundant):
rtc.setClockSource(rtc.RTC_LSE_CLOCK);

Since the enum is already defined inside the class, we don't really need (nor we want) to type another RTC_ prefix!

Instead, the RTC driver inside the core defines about the same enums at the global scope, without any prefix. Take for example:

typedef enum {
AM,
PM
} hourAM_PM_t;

I think those identifiers are way too generic to be at global scope without any prefix.

If you really want to re-define enums as members of the RTC class, I think the naming convention should be swapped: global enums get the RTC_ prefix, while member enums don't (like in early versions of the library).

This issue is more general and it is present in other drivers, such as "clock.h", that live in the "stm32" subdirectory of the core. Since this is part of the include chain, all those identifiers are always in the global namespace.

If you don't like prefixes, then maybe you should use some sort of namespace dedicated to the STM32 port, but that would require to use C++ source files (which Arduino core already does by the way).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions