Skip to content

fix(dialog): make PJ_DIALOG_PLUGIN arg-count dispatch MSVC-legacy-preprocessor-safe#153

Merged
facontidavide merged 2 commits into
mainfrom
fix/dialog-macro-msvc-preprocessor
Jul 18, 2026
Merged

fix(dialog): make PJ_DIALOG_PLUGIN arg-count dispatch MSVC-legacy-preprocessor-safe#153
facontidavide merged 2 commits into
mainfrom
fix/dialog-macro-msvc-preprocessor

Conversation

@facontidavide

Copy link
Copy Markdown
Contributor

The bug

The SDK's recommended two-arg PJ_DIALOG_PLUGIN(Class, kManifest) form mis-expands under MSVC's traditional preprocessor (the default — /Zc:preprocessor off): __VA_ARGS__ forwarded into PJ_DIALOG_PLUGIN_SELECT arrives as a single glued argument, so the arity dispatch picks the one-arg LEGACY branch with "Class, kManifest" as ClassNameC2064 (new Class, kManifest()) and C2912 (dialogVtableFor<Class, &kManifest>) at every call site. Found by pj-official-plugins#230's Windows CI.

Why three layers of protection all missed it:

  • The SDK's own Windows CI builds everything with /Zc:preprocessor (in PJ_WARNING_FLAGS), so the legacy-PP path of the macro was never compiled anywhere.
  • pj_dialog_sdk carried an INTERFACE /Zc:preprocessor flag for CMake consumers — but Conan's CMakeDeps regenerates targets from package_info() and drops upstream INTERFACE_COMPILE_OPTIONS, so Conan consumers (the official plugins) never received it.

The fix

  1. PJ_DIALOG_PLUGIN_EXPAND rescan around the selected call — the canonical MSVC workaround. The macro now expands identically under both MSVC preprocessors and GCC/Clang. Header-only; no ABI change, no call-site change; the existing docs' two-arg examples become true on Windows.
  2. Drop the INTERFACE /Zc:preprocessor injection from pj_dialog_sdk — no installed header requires it anymore (this was the only __VA_ARGS__ macro in the installed tree), and silently imposing a preprocessor mode on consumers was ineffective for the consumers that needed it. Consumer-visible: CMake consumers' TUs that include dialog headers will no longer be forced into conformant-PP mode — flag it if you'd rather keep it.
  3. New regression target mock_dialog_legacy_pp_plugin — compiles the mock dialog with /Zc:preprocessor- on MSVC, so windows-ci now exercises the exact path that broke (no-op extra compile on other platforms).

Versioning

Recorded in the CHANGELOG under the in-flight 0.18.0 — no version bump in this PR per Davide. abi/baseline.abi untouched (header macro + build-system only).

Validation

  • ./build.sh --debug && ./test.sh49/49 tests pass.
  • Both mock-dialog targets rebuilt clean after clang-format.
  • The MSVC legacy-PP failure mode is reproduced/covered by the new CI target (will be exercised by windows-ci on this PR).

🤖 Generated with Claude Code

facontidavide and others added 2 commits July 18, 2026 14:55
…processor-safe

The two-arg PJ_DIALOG_PLUGIN(Class, kManifest) form mis-expanded under
MSVC's traditional preprocessor (the default without /Zc:preprocessor):
__VA_ARGS__ forwarded into PJ_DIALOG_PLUGIN_SELECT arrives as a single
glued argument, so the dispatch picks the one-arg LEGACY branch with
"Class, kManifest" as ClassName (C2064/C2912 at the call site). Found
via pj-official-plugins#230's Windows CI.

- Add the canonical PJ_DIALOG_PLUGIN_EXPAND rescan around the selected
  call, making the macro expand identically under both MSVC
  preprocessors and GCC/Clang. Header-only; no ABI or call-site change.
- Drop the INTERFACE /Zc:preprocessor injection from pj_dialog_sdk: it
  is no longer needed, imposed a preprocessor mode on consumers, and
  never reached Conan consumers anyway (CMakeDeps regenerates targets
  from package_info() and drops upstream INTERFACE_COMPILE_OPTIONS —
  which is exactly how this shipped unnoticed).
- Add mock_dialog_legacy_pp_plugin, a compile-only regression target
  built with /Zc:preprocessor- on MSVC, so Windows CI now exercises the
  legacy-preprocessor path the conformant-only SDK build never covered.
- CHANGELOG: recorded under the in-flight 0.18.0 (no version bump —
  folds into the upcoming release).

Validated: ./build.sh --debug && ./test.sh — 49/49 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@facontidavide
facontidavide merged commit 7abaccb into main Jul 18, 2026
4 checks passed
@facontidavide
facontidavide deleted the fix/dialog-macro-msvc-preprocessor branch July 18, 2026 13:03
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