(Hopefully an) Improvement: Separate eclass variables into extern (C) and constexpr (C++) variables#1942
Merged
sandro-elsweijer merged 3 commits intomainfrom Nov 10, 2025
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1942 +/- ##
==========================================
+ Coverage 75.64% 75.66% +0.02%
==========================================
Files 103 105 +2
Lines 18623 18646 +23
==========================================
+ Hits 14087 14109 +22
- Misses 4536 4537 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lenaploetzke
previously approved these changes
Nov 6, 2025
Collaborator
lenaploetzke
left a comment
There was a problem hiding this comment.
Nice, I kind of like the solution.
lenaploetzke
approved these changes
Nov 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1943
Describe your changes here:
Possibly the worst PR I ever made.
To be able to use the eclass variables in constexpr contexts the variables themselves have to be constexpr.
But since C does not understand constexpr and since we still have C files, the only option was to define these variables twice.
One extern C and one constexpr C++ version.
To keep the code duplication as low as possible, the variables are first defined as compiler macro.
After that the variables are generated from the macros.
Lastly, the compiler macros are undefined, so that they do not leak and cannot be used anywhere else.
I am not happy about this, but it is the best option I could come up with.
All these boxes must be checked by the AUTHOR before requesting review:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.All these boxes must be checked by the REVIEWERS before merging the pull request:
As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.
General
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
script/find_all_source_files.scpto check the indentation of these files.License
doc/(or already has one).