Skip to content

Give options a designated initializer to make crossreferencing their usage easier - #905

Merged
bicarus-dev merged 1 commit into
spice2x:mainfrom
mon:designated_init_options
Sep 7, 2026
Merged

bicarus-dev merged 1 commit into
spice2x:mainfrom
mon:designated_init_options

Conversation

@mon

@mon mon commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Description of change

This always bothered me, you have a commandline arg and it's a massive pain in the ass to work out where it's used because the flag never really matches the enum name.

Array designated initializers are a C99 extension that clang+gcc both support. I suspect msvc still blows up, but are people still using that? I can change it to a std::invoke lambda instead.

Chose to drop the (unused?) option sorting func because, well, unused.

Testing

Builds in CI, didn't do much more intense testing.

@mon

mon commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Shall I add a CI step for MSVC then? Then I could move to the other approach with confidence

@mon

mon commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Can't be that many people on MSVC because it appears to have been broken for the last 17 months :P CI is so very slow, PR coming assuming it succeeds.

@mon
mon force-pushed the designated_init_options branch from 998d891 to 14042cf Compare September 7, 2026 06:14
@mon

mon commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

So, this now works but I was considering yet another useless refactor: ditch the enum, turn the thing into a packed struct, and expose that for people who want to iterate it as a std::span. The static init function is absolutely massive, if it were turned into a constexpr it'd be quite pleasant.

That would require a larger change, that being changing the overlay code to accept string_view instead of just const char*, but I think it's doable since imgui itself uses start/end of a string and does not need the NUL terminator.

@mon

mon commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Changed my mind; the options parsing also creates a vector where order is important and indexed via the enum. This is fine for now.

@bicarus-dev
bicarus-dev merged commit 112b1ae into spice2x:main Sep 7, 2026
3 checks passed
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.

1 participant