Skip to content

Allow access to enum NUM_CONSTANTS field in FPP #887

@celskeggs

Description

@celskeggs

I'm seeing engineers define enums like the following:

        enum MyEnum : U8 {
            OPTION_A
            OPTION_B
            OPTION_C
            NUM_OPTIONS
        }

Of course, NUM_OPTIONS isn't supposed to be a valid choice for this enum... but the engineer wants the ability to use the number of values in the enum in a port array definition:

        output port myPort: [MyEnum.NUM_OPTIONS] MyPort

If we were writing C++, we could use MyEnum::NUM_CONSTANTS to find the number of options, and we wouldn't need to define NUM_OPTIONS. But we can't write MyEnum.NUM_CONSTANTS in fpp; the symbol is undefined.

I'd like for us to consider allowing FPP code to access the same NUM_CONSTANTS field that is available in the generated HPP.

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