<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/127963>127963</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang modules cannot compile most recent Windows SDK header
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kamrann
      </td>
    </tr>
</table>

<pre>
    Recently Microsoft appears to have made `10.0.26100.0` the default version of the SDK. A change to `wchar.h` in this version has broken projects that were previously compiling successfully with clang on Windows with C++20 modules enabled.

Simple repro:

```
// repro.mxx

module;
#include <cwchar>

export module repro;

export inline wchar_t const* func()
{
 return wmemchr(L"x", L'x', 1);
}
```

```
// source.cxx

import repro;

#include <cwchar>
```

Output:
```
In file included from C:\Code\build2-test-projects\hello\hello\clang\source.cxx:4:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.44.34823\include\cwchar:12:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\wchar.h:209:31: error: redefinition of '_Avx2WmemEnabledWeakValue'
  209 | __declspec(selectany) int _Avx2WmemEnabledWeakValue = 0;
      | ^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\wchar.h:209:31: note: previous definition is here
  209 |     __declspec(selectany) int _Avx2WmemEnabledWeakValue = 0;
      |                               ^
1 error generated.
```

The issue seems to relate to handling of the Microsoft-specific `__declspec(selectany)`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VUFv2zgT_TXjyyACRVmyddBBkWugaD98i03RHgOaGlncUKRBUrbz7xeU5DRetDktlgjAmJqZN2848yi8V0dDVEH-CPluJcbQW1e9iMEJY1YH275Wf5IkE_Qr_k9JZ73tAorTiYTzGCz24kw4iJYQCpayhCW8SBlLGBQMQ0_YUidGHfBMzitr0HbT8dPuS4I1yl6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