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.

@bicarus-dev

Copy link
Copy Markdown
Member

Can't break MSVC, I've seen plenty of people using that.

@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

@bicarus-dev

bicarus-dev commented Sep 6, 2026

Copy link
Copy Markdown
Member

That would be appreciated of course! Apparently it'll produce a billion warnings though.

People occasionally submit fixes to make MSVC work again so the current state may not even compile.

@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.

bicarus-dev pushed a commit that referenced this pull request Sep 7, 2026
Yess yessss let's continue supporting the worst compiler toolchain
:smiling_imp:

Fell out of the changes in #905

CI changes were claude because I cannot be arsed with yaml.

Can explain the individual code fixes if ya want any more context.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@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.

@bicarus-dev

Copy link
Copy Markdown
Member

Sounds good to me. This is one of the worst parts in this code base so any improvement is welcome

@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.

2 participants