Skip to content

UI: fix static initialization#1643

Merged
Exzap merged 1 commit into
cemu-project:mainfrom
oltolm:static_init
Jul 22, 2025
Merged

UI: fix static initialization#1643
Exzap merged 1 commit into
cemu-project:mainfrom
oltolm:static_init

Conversation

@oltolm

@oltolm oltolm commented Jul 13, 2025

Copy link
Copy Markdown
Contributor

#1519 has problems with static initialization. It happens to work sometimes with some compilers, but my builds simply crash at start.

I fixed it by doing static initialization on demand.

@Crementif

Copy link
Copy Markdown
Member

Just curious, but what was the compiler and compiler version you used to compile Cemu with? Is it a memory-usage related issue?

@oltolm

oltolm commented Jul 16, 2025

Copy link
Copy Markdown
Contributor Author

I used Clang 20 for Windows. I think the problem is https://isocpp.org/wiki/faq/ctors#static-init-order. Basically the order of static initialization is undefined if it happens in multiple compilation units.

@Exzap

Exzap commented Jul 20, 2025

Copy link
Copy Markdown
Member

Preferable solution is to initialize both maps at runtime in HotkeySettings::Init, it's more compact, doesn't hurt compile time or performance due to all the encapsulation and static accessors (even if the cost is negligible), is less LoC and it seems to be more in line with what the original author intended (since s_keyboardHotkeyToFuncMap is already initialized in Init()).

@oltolm

oltolm commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

done

@Exzap Exzap merged commit 955ce9b into cemu-project:main Jul 22, 2025
6 checks passed
@Exzap

Exzap commented Jul 22, 2025

Copy link
Copy Markdown
Member

thanks!

@oltolm oltolm deleted the static_init branch July 22, 2025 23:06
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