Skip to content

fix: rename small enum members to dodge windows sdk macro collision#357

Merged
webern merged 1 commit into
mainfrom
claude/issue-354-small-keyword-xoho6d
Jul 15, 2026
Merged

fix: rename small enum members to dodge windows sdk macro collision#357
webern merged 1 commit into
mainfrom
claude/issue-354-small-keyword-xoho6d

Conversation

@webern

@webern webern commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

The Windows SDK's rpcndr.h (pulled in transitively by windows.h) #defines small to char. Any generated or hand-written small identifier gets textually replaced by the preprocessor before the compiler ever parses it, so both mx::api::CssSize::small and mx::core::CSSFontSize's small/small() broke under MSVC once windows.h was included first.

Per the issue's suggested resolution, renamed the enumerator to small_ in both layers, on the theory that if it bites the public mx::api header it can just as easily bite mx::core's generated header:

  • mx::api::CssSize::small -> small_ (FontData.h)
  • mx::core::CSSFontSize::Tag::small / CSSFontSize::small() -> small_ (generated)
  • gen/cpp/config.toml: added "small" to the C++ target's [reserved] words so make gen-cpp keeps mangling it on regeneration, with a comment explaining why
  • mx::impl::Converter::cssMap updated to the new names

The on-the-wire spelling ("small" in MusicXML CSS font-size values) is untouched — only the C++ identifiers changed. This is a breaking change to the public CssSize enum, as the issue anticipated; there's no existing deprecation/compat-shim convention in this codebase to soften it, so it's a straight rename.

Testing

  • python3 -m gen gen/cpp/config.toml — regenerated cleanly, touching only CSSFontSize.h/.cpp as expected
  • clang-format --dry-run --Werror on all touched files — clean
  • Did not run the full native/Docker build or test suite in this session; CI will need to confirm core-roundtrip-test and api-test pass

References

rpcndr.h (pulled in transitively by windows.h) #defines `small` to
`char`, so any generated or hand-written `small` identifier gets
mangled before the compiler ever sees it. Renamed to `small_` in both
mx::api's CssSize and mx::core's generated CSSFontSize, and added
"small" to the C++ target's [reserved] words in gen/cpp/config.toml so
regeneration keeps mangling it. The wire spelling ("small") and
mx::impl's conversion map are unaffected.

Fixes #354
@webern webern added the ai Issues opened by, or through, a coding agent. label Jul 15, 2026 — with Claude
@github-actions

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit 1b8a1f20b76bf9e574eec2c2051010a136232381.

@webern
webern merged commit 0f16815 into main Jul 15, 2026
7 checks passed
@webern
webern deleted the claude/issue-354-small-keyword-xoho6d branch July 15, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Issues opened by, or through, a coding agent.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FontData.h: small enum value conflicts with Windows SDK rpcndr.h macro

1 participant