Skip to content

Macros #8

@ashley-hawkins

Description

@ashley-hawkins

Macros that define compile time constants can probably be exported as constexpr auto variables. I am worried that there could be corner cases where it would have different semantics from the macro though.

I could imagine it generating something like export inline constexpr auto GENCPPM_SOMEMACRO = SOMEMACRO; though I can think of ways to maybe make it nicer and avoid the GENCPPM_ prefix. In that case where SOMEMACRO defines a compile time constant, it is a rvalue whilst GENCPPM_SOMEMACRO is a const lvalue. I think another way would be to make it export a consteval function which returns the macro's value, which although it would be weird (you'd do like GENCPPM_SOMEMACRO() instead of GENCPPM_SOMEMACRO), would act more similarly to the macro since the result of GENCPPM_SOMEMACRO() would be a prvalue, the same as a macro which expands to a compile time constant. Maybe the strategy could be a switch where the user chooses which one to use. Or maybe the function one should just be preferred because it seems like it would be closer to the semantics of the original macros.

Related to #6 and #4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions