Bug: Standard library headers included inside module purview of `winrt_numerics.ixx`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- cpp
- 领域
- build-system
调研方向
Start with winrt_numerics.ixx and windowsnumerics.impl.h, then inspect the WindowsNumerics.inl includes in the Windows SDK and the mingw-w64 headers named in the report. Reproduce the module build with GCC or Clang and compare it with MSVC. Done when required standard headers are included in the global module fragment and the DirectX interop functions are exported, with the reported module conflicts resolved.
由索引模型根据 Issue 内容生成。
描述
Version
3.0.260818.1
Summary
In C++20 module builds (-modules), winrt_numerics.ixx only pre-includes <directxmath.h> in its global module fragment before declaring export module winrt_numerics; and including <windowsnumerics.impl.h> inside the module purview.
However, <windowsnumerics.impl.h> transitively includes standard library headers (<stdexcept> and <limits> via WindowsNumerics.inl in the Windows SDK, and <algorithm> and <cmath> in mingw-w64). Because those headers are not pre-included in the global module fragment, they are expanded directly inside the purview of winrt_numerics:
- GCC (libstdc++) and Clang (libc++) attach those standard library declarations to the named module
winrt_numerics, conflicting with earlier global module declarations from<version>and causingwinrt_numerics.ixxto fail to compile. - MSVC masks this only because its standard library headers wrap
namespace stdinextern "C++", andwinrt_numerics.ixxsuppresses warning'#include <stdexcept>' in the purview of module 'winrt_numerics' appears erroneouswith#pragma warning(disable : 5244).
In addition, the DirectX interop functions (XMLoadFloat2, XMStoreFloat2, etc.) in <windowsnumerics.impl.h> are declared outside _WINDOWS_NUMERICS_BEGIN_NAMESPACE_, leaving them unexported and attached to winrt_numerics even on MSVC.
Reproducible example
$out = Join-Path $env:TEMP "cppwinrt_numerics_repro"
Remove-Item -Recurse -Force $out -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $out | Out-Null
Push-Location $out
# 1. Generate module projection with cppwinrt 3.0.260818.1
$cppwinrt = "$env:USERPROFILE\.nuget\packages\microsoft.windows.cppwinrt\3.0.260818.1\bin\cppwinrt.exe"
& $cppwinrt -in local -out $out -modules -include Windows.Foundation
# 2. MSVC: succeeds because warning C5244 is suppressed and MSVC STL uses extern "C++"
$vsDevCmd = "C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\VsDevCmd.bat"
$msvcCmds = @(
"`"$vsDevCmd`" -arch=x64 -no_logo"
"cd /d `"$out`""
"cl /nologo /std:c++20 /EHsc /MD /I. /c /interface /TP winrt/winrt_numerics.ixx /ifcOutput winrt_numerics.ifc"
) -join " && "
cmd /c $msvcCmds
# 3. GCC: fails when compiling winrt/winrt_numerics.ixx directly
g++ -std=c++20 -fmodules -I. -x c++ -c winrt/winrt_numerics.ixx -o winrt_numerics.o
Pop-Location
MSVC output:
winrt_numerics.ixx
GCC output when compiling winrt/winrt_numerics.ixx:
In file included from C:/Tools/msys64/ucrt64/include/c++/16.2.0/bits/stl_algobase.h:63,
from C:/Tools/msys64/ucrt64/include/c++/16.2.0/algorithm:62,
from C:/Tools/msys64/ucrt64/include/windowsnumerics.impl.h:28,
from winrt/winrt_numerics.ixx:48:
C:/Tools/msys64/ucrt64/include/c++/16.2.0/bits/stl_pair.h:102:12: error: conflicting declaration of 'struct std::_Index_tuple<_Indexes>' in module 'winrt_numerics'
102 | struct _Index_tuple;
| ^~~~~~~~~~~~
In file included from C:/Tools/msys64/ucrt64/include/c++/16.2.0/bits/cpp_type_traits.h:42,
from C:/Tools/msys64/ucrt64/include/c++/16.2.0/bits/stl_algobase.h:60:
C:/Tools/msys64/ucrt64/include/c++/16.2.0/type_traits:4372:39: note: previously declared in global module
4372 | template<size_t... _Indexes> struct _Index_tuple { };
| ^~~~~~~~~~~~
In file included from C:/Tools/msys64/ucrt64/include/c++/16.2.0/cmath:55,
from C:/Tools/msys64/ucrt64/include/windowsnumerics.impl.h:29:
C:/Tools/msys64/ucrt64/include/math.h:150:10: error: conflicting declaration of 'struct _exception' in global module
150 | struct _exception {
| ^~~~~~~~~~
C:/Tools/msys64/ucrt64/include/math.h:15:8: note: previously declared in module 'winrt_numerics'
15 | struct _exception;
| ^~~~~~~~~~
Expected behavior
Pre-include the standard library headers required by <windowsnumerics.impl.h> in the global module fragment of winrt_numerics.ixx (or import std; before including <windowsnumerics.impl.h>), and ensure the DirectX interop functions in <windowsnumerics.impl.h> are also exported with WINRT_EXPORT.
Actual behavior
No response
Additional comments
No response
- 主要语言
- C++
- 星标
- 1.9k
- 派生
- 288
- 平均合并
- 18 小时 15 分钟
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/cppwinrt 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
microsoft/cppwinrt#1646 · 7 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/cppwinrt#1554 · 2 条评论 ·
维护者通常 1 天内回复
-
Bug: Unexported `extern "C"` block in `base.h` makes `WINRT_IMPL_*` declarations invisible to downstream modules可能已有人在做 @YexuanXiao 今天认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
microsoft/cppwinrt#1643 · 5 条评论 ·
维护者通常 1 天内回复
-
base_macros.h disables warnings without push/pop, leaking them into consumer translation units可能已有人在做 @DanielJump 于 64 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 20/100
维护者通常 1 天内回复
-
Bug: headers cannot be compiled at high warning levels (MSVC /Wall, clang)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 25/100
microsoft/cppwinrt#1620 · 3 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 microsoft/cppwinrt 的全部 Issue
相似的 Issue
-
bug libcudf
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
level/task module/cloud monitoring type/maintenance
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
LadybirdBrowser/ladybird#13809 ·
维护者通常 1 天内回复
-
bug module:nodes tests
难度 2/5 1-3 小时 新手友好度 78/100
rocketride-org/rocketride-server#3020 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 9 天内回复