Skip to content

chore: align all build configs on C++20#5

Merged
kryuchenko merged 1 commit into
mainfrom
chore/cxx20-everywhere
Apr 18, 2026
Merged

chore: align all build configs on C++20#5
kryuchenko merged 1 commit into
mainfrom
chore/cxx20-everywhere

Conversation

@kryuchenko
Copy link
Copy Markdown
Owner

Summary

The project set the C++ standard in three places with three different answers:

where was
.github/workflows/build.yml (raw cl) /std:c++20
CMakeLists.txt unset (MSVC default, ≈ C++14)
tests/CMakeLists.txt CMAKE_CXX_STANDARD 17

This gap is why the previous path_info extraction compiled fine under the manual /std:c++20 build but broke the CTest build: std::wstring::data() returns const wchar_t* in C++17 but wchar_t* in C++20, and the Win32 APIs want LPWSTR.

This PR:

  • Sets CMAKE_CXX_STANDARD 20 (required, extensions off) in both CMakeLists.txt files.
  • Drops the now-moot C++17 vs C++20 note from path_info.cpp — the workaround (&buf[0]) is still there and still correct, it just doesn't need to advertise its reason any more.

Test plan

  • build / windows-build: no change (they already used /std:c++20).
  • test (CTest): builds with C++20 now; GoogleTest supports C++20 fine.
  • Memory Safety Tests (ASan Debug): same — MSVC ASan is C++20-compatible.

Previously the standard was set in three places with three different
answers:

  - .github/workflows/build.yml invoked cl with /std:c++20 directly
  - CMakeLists.txt did not set CMAKE_CXX_STANDARD (MSVC default)
  - tests/CMakeLists.txt set CMAKE_CXX_STANDARD 17

That gap is why the prior path_info extraction compiled fine under the
manual /std:c++20 cl invocation but broke the CTest build: in C++17
std::wstring::data() returns const wchar_t*, and the Win32 APIs expect
LPWSTR.

Set CMAKE_CXX_STANDARD 20 (required, extensions off) in both
CMakeLists.txt files so the CMake-driven build, the CTest build, and
the raw-cl CI build all compile the same language. Drop the now-moot
C++17 vs C++20 comment in path_info.cpp.
@kryuchenko kryuchenko merged commit e28ef5c into main Apr 18, 2026
4 checks passed
@kryuchenko kryuchenko deleted the chore/cxx20-everywhere branch April 18, 2026 18:49
kryuchenko pushed a commit that referenced this pull request Apr 18, 2026
…ests

Splits the 2101-line monolithic cli_args_debugger.cpp into a thin window
class plus four composable modules, and fills the test gap along the way.
End state: cli_args_debugger.cpp down to ~1270 lines, zero functions over
the static-analysis CCN threshold, and 33 new unit tests covering the
extracted pure logic.

Modules extracted
-----------------

log_manager.{hpp,cpp}
  Owns g_log_file / g_logPath, InitLogger / Log / LogSEH / CloseLogger.
  Collapses the duplicated cleanup that was inlined in both branches of
  wWinMain. Keeps the extern globals so tests/logging_tests.cpp links
  unchanged.

path_info.{hpp,cpp}  (namespace path_info)
  Hosts ExecutablePath / CurrentWorkingDirectory / TempDirectory /
  WindowsDirectory / SystemDirectory / OsVersionString /
  WineOrProtonVersion / SaveFilePath / Collect. While moving the code:
    - MAX_PATH truncation fixed in five Win32 helpers via growing-retry
      / queried-size patterns.
    - C-style casts on GetProcAddress → reinterpret_cast.
    - exeDir = exeDir.substr(0, slash) → in-place erase.
    - Wrapped under a namespace so Windows.h macros like
      GetWindowsDirectory don't rewrite the function names.

audio_capture.{hpp,cpp}  (class AudioCapture)
  Pulls the entire WASAPI pipeline out of ArgumentDebuggerWindow: the
  11 audio data members, InitializeMicrophone, PollMicrophone (CCN 50,
  the worst function in the codebase), the capture thread entry, and
  the audio slice of OnDestroy/Cleanup. The seh_wrapper TU now casts
  its LPVOID straight to AudioCapture* and calls ThreadMain, so the
  main class no longer leaks into it. PollMicrophone is split into
  ResolveFormat + four per-format peak helpers + a dispatch; highest
  resulting CCN is 16.

RenderFrame split in place
  The CCN-21, 289-line RenderFrame is replaced by a ~20-line orchestrator
  plus ten private section methods (UpdateFrameTiming, RenderCube,
  RenderTextHud, RenderLoadedDataPanel, RenderPathsPanel,
  RenderInputPrompt, RenderQrBitmap, RenderVolumeMeter, EndOverlay,
  PresentFrame). No behaviour change — each helper draws the same
  region in the same order; EndOverlay's bool return mirrors the
  original device-lost early return.

Build system
------------
CMAKE_CXX_STANDARD 20 (required, extensions off) is set in both
CMakeLists.txt files, aligning the CMake/CTest builds with the
/std:c++20 flag already used by the raw-cl path in build.yml. Prior to
this, CMakeLists.txt left the standard unset (MSVC default ≈ C++14)
and tests/CMakeLists.txt pinned C++17, which is why
std::wstring::data() appeared to work for the main exe but broke
CTest compilation.

Tests
-----
tests/audio_peak_tests.cpp — 22 GoogleTest cases covering PeakFloat32,
PeakPcm16, PeakPcm24, PeakPcm32, PeakForFormat dispatch, ResolveFormat
for plain WAVEFORMATEX and WAVEFORMATEXTENSIBLE unwrapping. Includes
the 24-bit sign-extension edge case that used to be buried in
PollMicrophone, the "unsupported format degrades to 0" contract, and
the zero-channel-count fallback.

tests/path_info_tests.cpp — 11 smoke tests covering every path_info::
helper plus Collect(). Validates the growing-buffer / queried-size
patterns don't truncate, and pins Collect()'s label order so a future
accidental reorder surfaces as a test failure.

To keep these helpers testable without a live microphone, the
anonymous-namespace peak helpers in audio_capture.cpp are promoted
into audio_capture::detail.

Numbers
-------
                         before   after
cli_args_debugger.cpp    2101    ~1270   (-40 %)
functions with CCN > 15     2       0
average CCN (main file)   6.4     3.4
highest CCN (main file)    50       7   (WindowProc)
test suites                12      14

Squash of PRs #3, #4, #5, #6, #7, #8.
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