Skip to content

Replace C macros by C++ constexpr #3399

Open
@JanVogelsang

Description

@JanVogelsang

In the code we make extensive use of C macros to enable/disable certain regions of code based on compiler flags. These C macros could be replaced by C++ constexpr equivalents and

#define ENABLE_FEATURE 1
#if ENABLE_FEATURE
...
#endif

by

constexpr bool enable_feature = true;
if constexpr (enable_feature) {
...
}

This way all code would always be checked by the compiler independent of the local compiler flags, which reduces possible errors that one doesn't catch locally.
Maybe there is a way for CMake to create constexpr variables directly instead of defining C macro variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I: No breaking changePreviously written code will work as before, no one should note anything changing (aside the fix)S: NormalHandle this with default prioritygood first issueGood for newcomers

    Projects

    Status

    To do (open issues)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions