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

Avoid using static global variables in Constants #56

Open
jlbabilino opened this issue Mar 29, 2023 · 1 comment
Open

Avoid using static global variables in Constants #56

jlbabilino opened this issue Mar 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@jlbabilino
Copy link
Member

This can cause issues across shared object boundaries, only ever use constexpr in Constants.hpp.

One way to fix this is to convert this:

const MyType value;

to

const MyType& GetVal() {
  static MyType val;
  return val;
}
@calcmogul
Copy link
Member

constexpr MyType value; will work as well as long as there's a constexpr constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants