From 33fa28e9592778723fc4e4bd3f81eec5108deb6c Mon Sep 17 00:00:00 2001 From: Matthew James Briggs Date: Wed, 15 Jul 2026 20:42:51 +0000 Subject: [PATCH] fix: rename small enum members to dodge windows sdk macro collision 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/cpp/config.toml | 4 ++++ src/include/mx/api/FontData.h | 4 +++- src/private/mx/core/generated/CSSFontSize.cpp | 4 ++-- src/private/mx/core/generated/CSSFontSize.h | 4 ++-- src/private/mx/impl/Converter.cpp | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gen/cpp/config.toml b/gen/cpp/config.toml index 81e86a85f..9dd494a18 100644 --- a/gen/cpp/config.toml +++ b/gen/cpp/config.toml @@ -71,6 +71,9 @@ non_negative_integer = "int" [reserved] # C++ keywords (including alternative tokens) a generated identifier must not be. +# "small" is also here though it is not a keyword: the Windows SDK's rpcndr.h +# (pulled in transitively by windows.h) #defines it to `char`, which mangles +# any generated `small` identifier before the compiler ever sees it (#354). words = [ "alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char8_t", @@ -87,6 +90,7 @@ words = [ "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq", + "small", ] # Semantic names for the synthesized content types the ยง2.9 projection diff --git a/src/include/mx/api/FontData.h b/src/include/mx/api/FontData.h index 77f30b5e4..1322e6fda 100644 --- a/src/include/mx/api/FontData.h +++ b/src/include/mx/api/FontData.h @@ -28,7 +28,9 @@ enum class CssSize unspecified, xxSmall, xSmall, - small, + // Named small_, not small: the Windows SDK's rpcndr.h (pulled in + // transitively by windows.h) #defines `small` to `char` (#354). + small_, medium, large, xLarge, diff --git a/src/private/mx/core/generated/CSSFontSize.cpp b/src/private/mx/core/generated/CSSFontSize.cpp index 7780b8d7a..1726eb021 100644 --- a/src/private/mx/core/generated/CSSFontSize.cpp +++ b/src/private/mx/core/generated/CSSFontSize.cpp @@ -22,9 +22,9 @@ CSSFontSize CSSFontSize::xSmall() noexcept return CSSFontSize{Tag::xSmall}; } -CSSFontSize CSSFontSize::small() noexcept +CSSFontSize CSSFontSize::small_() noexcept { - return CSSFontSize{Tag::small}; + return CSSFontSize{Tag::small_}; } CSSFontSize CSSFontSize::medium() noexcept diff --git a/src/private/mx/core/generated/CSSFontSize.h b/src/private/mx/core/generated/CSSFontSize.h index 02c242e95..0a7b7fa3a 100644 --- a/src/private/mx/core/generated/CSSFontSize.h +++ b/src/private/mx/core/generated/CSSFontSize.h @@ -18,7 +18,7 @@ class CSSFontSize final { xxSmall, xSmall, - small, + small_, medium, large, xLarge, @@ -30,7 +30,7 @@ class CSSFontSize final static CSSFontSize xxSmall() noexcept; static CSSFontSize xSmall() noexcept; - static CSSFontSize small() noexcept; + static CSSFontSize small_() noexcept; static CSSFontSize medium() noexcept; static CSSFontSize large() noexcept; static CSSFontSize xLarge() noexcept; diff --git a/src/private/mx/impl/Converter.cpp b/src/private/mx/impl/Converter.cpp index 299c14220..2ecb03f3e 100644 --- a/src/private/mx/impl/Converter.cpp +++ b/src/private/mx/impl/Converter.cpp @@ -152,7 +152,7 @@ const Converter::EnumMap Conver const Converter::EnumMap Converter::cssMap = { {core::CSSFontSize::xxSmall(), api::CssSize::xxSmall}, {core::CSSFontSize::xSmall(), api::CssSize::xSmall}, - {core::CSSFontSize::small(), api::CssSize::small}, {core::CSSFontSize::medium(), api::CssSize::medium}, + {core::CSSFontSize::small_(), api::CssSize::small_}, {core::CSSFontSize::medium(), api::CssSize::medium}, {core::CSSFontSize::large(), api::CssSize::large}, {core::CSSFontSize::xLarge(), api::CssSize::xLarge}, {core::CSSFontSize::xxLarge(), api::CssSize::xxLarge}, };