You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C++ generator emits non-const static data members with in-class initializers (static int count = 0;), which doesn't compile #80
For a static field that isn't constant, CppGenerator.SpellStorage (Coder/Languages/CppGenerator.cs:~790-798) returns "static ". GenerateFieldDeclaration (~565-585) then always adds an initializer: either = value or {}.
It emits static int count = 0; inside the class. g++ -std=c++20 rejects this with "ISO C++ forbids in-class initialization of non-const static member 'Cfg::count'". Dropping the initializer doesn't help: the generator then emits static int count{};, which fails with the same error.
Every class with a mutable static field therefore produces uncompilable C++.
Suggested fix
Inside a type, spell a non-const static field as inline static (C++17), which permits an in-class initializer:
inlinestaticint count = 0;
Add a test that compiles, or at least snapshots, a class with a mutable static field.
Priority: Medium. Any class with a mutable static field generates C++ that does not compile. The compiler reports it loudly, so nothing is silently wrong, and the fix (inline static) is a one-line spelling change.
Area / suggested owner: C++ generator (CppGenerator.SpellStorage / GenerateFieldDeclaration)
Activity
matt-edmondson commentedon Sep 26, 2026
Triage
inline static) is a one-line spelling change.CppGenerator.SpellStorage/GenerateFieldDeclaration)Generated by Claude Code