我正在尝试 MSVC 和模块。
我有以下代码:
module;
#include "windows.h"
export module Module;
当我在
Win32
配置中编译它时,我得到以下信息:
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(1005,1): message : sorry: 'inline' function definition for 'ULONGLONG Int64ShllMod32(ULONGLONG,DWORD)' could not be written to module due to unrecognized expression or statement at 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(1010,5)'.
1>If possible please provide a repro here: https://developercommunity.visualstudio.com
函数
LONGLONG Int64ShraMod32(LONGLONG,DWORD)
和 ULONGLONG Int64ShrlMod32(ULONGLONG,DWORD)
也会发生同样的情况。
该消息不会在
x64
配置中显示。
所以我想知道:
我正在使用 Visual Studio 2022 版本 17.5.0 (v143) 并使用
/std:c++20
进行编译。
我遇到过与你遇到的问题类似的事故,所以我不确定这是否有帮助,但我会尽力回答。
...就我而言,它是在我使用 Visual Studio 创建项目时发生的。 据此,编译器可以将头文件识别为编译目标。 证明位于解决方案中包含的 .vcproj 中。
<ClCompile Include="srcfile.cpp" />
用 vcproj 编写的“srcfile.cpp”必须仅包含源文件。 如果此处包含头文件,编译器将对其进行编译并查找“内联”函数。因此,下面的例子是NG的。
<ClCompile Include="srcfile.h" />
头文件需要重写如下并包含在附近的块中。
<ClInclude Include="srcfile.h" />
我的观点可能是错误的,或者标题中的问题可能是由其他原因引起的。 另外,我是日本人,不太懂英语。抱歉。