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

Use constexpr constants instead of defines. #4

Merged
merged 4 commits into from
Mar 6, 2024
Merged

Conversation

Klaim
Copy link
Collaborator

@Klaim Klaim commented Feb 13, 2024

This is both to avoid using the preprocessor in C++ in general, and to prepare for future usage of the library as a C++ module.

Copy link
Collaborator

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using constinit?

@Klaim
Copy link
Collaborator Author

Klaim commented Mar 6, 2024

@jjerphan

How about using constinit?

constinit is useful for runtime static/global/namespace objects to guarantee that their initialization is compile-time, but they are neither const nor compile-time themselves.

The version number needs to be both compile-time and runtime and be kept const (bascially immutable), so the only option is constexpr.

constinit can be confusing, it's basically only useful to help with the "static init fiasco" issue.

This is both to avoid using the preprocessor in C++ in general,
and to prepare for future usage of the library as a C++ module.
@JohanMabille JohanMabille merged commit 799b3ce into main Mar 6, 2024
6 checks passed
@JohanMabille JohanMabille deleted the klaim/modules branch March 6, 2024 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants