-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
5 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
b94ad5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this is beneficial.
In a modern compiler (Such as one that would support c2x), The end code is optimized so that the difference between the 2 is nonexistent, On GCC 13.2.1 (amd64), they produce the exact same executable.
I'm not saying that
constexpr
isn't useful, but the only thing that this patch does is make the program harder to build. (The version with the#define
's actually was strictly compliment with not only c11, but c99 too!).Simple
#define
macros that are essentially numbers don't usually make warnings and errors harder to track like they do in#define
-ed functions. Nor does it make the code significantly uncleaner. Nor is there any attempt to take the address of these variables, and since they are redefined as constants there's no attempt to modify them.Anyways, the program is much easier to build with older compilers without this commit. And the end result is the same for any compiler that does constant folding.
b94ad5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliverkwebb
b94ad5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliverkwebb After having tried to port the program from C to Zig, it really does not feel like an improvement. I agree that if the program should stay as C, it can just as well support C11 as well.
So, now the defines are back. I will try to port it to a more memory safe language than C, sooner or later, but for now, it's C11.