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

static just like const can only be literals #5

Closed
mardaravicius opened this issue Dec 9, 2024 · 2 comments
Closed

static just like const can only be literals #5

mardaravicius opened this issue Dec 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mardaravicius
Copy link

mardaravicius commented Dec 9, 2024

static int s = xsGetRandomNumber();

would produce an error

Error 0334 `xsGetRandomNumber` is not a valid variable for an integer constant.

but the checker says it's fine

of course, unlike const, they can be changed to another value that is not a literal

static int s = 0;
s = xsGetRandomNumber(); /* this is fine */
@Divy1211
Copy link
Owner

Divy1211 commented Dec 9, 2024

That makes sense, a static variable has program lifetime, it must be defined by a constexpr. I can add this check, thanks for the report

@Divy1211
Copy link
Owner

Divy1211 commented Dec 9, 2024

Fixed in v0.1.3

@Divy1211 Divy1211 closed this as completed Dec 9, 2024
@Divy1211 Divy1211 added the bug Something isn't working label Dec 9, 2024
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