fix: rename small enum members to dodge windows sdk macro collision#357
Merged
Conversation
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
gen-quality
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Windows SDK's
rpcndr.h(pulled in transitively bywindows.h)#definessmalltochar. Any generated or hand-writtensmallidentifier gets textually replaced by the preprocessor before the compiler ever parses it, so bothmx::api::CssSize::smallandmx::core::CSSFontSize'ssmall/small()broke under MSVC oncewindows.hwas included first.Per the issue's suggested resolution, renamed the enumerator to
small_in both layers, on the theory that if it bites the publicmx::apiheader it can just as easily bitemx::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 somake gen-cppkeeps mangling it on regeneration, with a comment explaining whymx::impl::Converter::cssMapupdated to the new namesThe 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 publicCssSizeenum, 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 onlyCSSFontSize.h/.cppas expectedclang-format --dry-run --Werroron all touched files — cleancore-roundtrip-testandapi-testpassReferences
smallenum value conflicts with Windows SDKrpcndr.hmacro #354