Bug: Unexported `extern "C"` block in `base.h` makes `WINRT_IMPL_*` declarations invisible to downstream modules

オープン
#1,643 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@YexuanXiao がすでに取り組んでいます。

2026年11月4日 から。

  • #1644 @YexuanXiao による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
cpp
領域
build-system

調査の方向性

Start with the first extern "C" block in base.h and the references in Windows.Foundation.h from wait_for_completed and when_any; the issue identifies winrt.Windows.Foundation.ixx as a place where Clang reports the visibility error. Check how winrt_base exports declarations used by downstream modules, then build the module with Clang to confirm the reported failure is resolved.

索引モデルが issue の本文から書いたものです。

説明

Version

3.0.260818.1

Summary

In module builds, base.h is included in the module purview of winrt_base, and winrt.Windows.Foundation gets its base.h declarations via export import winrt_base;.

The first extern "C" block in base.h (declaring WINRT_IMPL_* functions) is not marked export. When Windows.Foundation.h calls WINRT_IMPL_CreateEventW, WINRT_IMPL_SetEvent, and WINRT_IMPL_WaitForSingleObject (in wait_for_completed and when_any), these functions are not visible to name lookup in winrt.Windows.Foundation.

extern "C" in a module purview only specifies C language linkage and global module ownership; it does not export the declarations. MSVC currently masks this bug by exposing unexported extern "C" declarations to importing modules, whereas Clang rejects winrt.Windows.Foundation.ixx with an undeclared/invisible identifier error.

Expected behavior

All declarations in winrt_base that are referenced by downstream namespace modules or generated component files (module.g.cpp) should either be explicitly exported (WINRT_EXPORT / export extern "C") or placed in a shared header included in the global module fragment.

Actual behavior

No response

Additional comments

A few related module-visibility mismatches stem from the same pattern in module builds:

1. Missing <intrin.h> in winrt.Windows.Foundation.ixx: <intrin.h> is only included in the global module fragments of winrt_base.ixx and winrt_numerics.ixx, but strings/base_coroutine_foundation.h (winrt::when_any) directly calls _InterlockedCompareExchangePointer inside winrt.Windows.Foundation.
2. Inconsistent linkage/export specifiers on namespace std specializations:
- strings/base_std_hash.h, strings/base_coroutine_threadpool.h, and strings/base_coroutine_foundation.h use WINRT_IMPL_STD_EXPORT namespace std (extern "C++" without export).
- strings/base_collections_map.h uses WINRT_EXPORT namespace std (export extern "C++").
- strings/base_string.h, strings/base_stringable_format.h, strings/base_stringable_format_1.h, and wrap_std_namespace in cppwinrt/code_writers.h declare std::hash and std::formatter specializations inside the module purview without extern "C++" or export, attaching std specializations to named modules.

主要言語
C++
スター
1.9k
フォーク
288
平均マージ
18時間 15分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/cppwinrt のほかの issue

microsoft/cppwinrt の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。