Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace C macros by C++ constexpr #3399

Open
JanVogelsang opened this issue Feb 6, 2025 · 1 comment
Open

Replace C macros by C++ constexpr #3399

JanVogelsang opened this issue Feb 6, 2025 · 1 comment
Labels
good first issue Good for newcomers I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority

Comments

@JanVogelsang
Copy link
Contributor

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.

@JanVogelsang JanVogelsang added good first issue Good for newcomers I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority labels Feb 6, 2025
@github-project-automation github-project-automation bot moved this to To do (open issues) in Kernel Feb 6, 2025
@sameep-git
Copy link

Hi, I would like to help with this issue. I am new to open-source and nest. Could you tell me more about what your approach to this problem is? Are we trying to replace the code for every instance of this in the codebase or just some particular ones?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority
Projects
Status: To do (open issues)
Development

No branches or pull requests

2 participants