当我尝试在 Visual Studio 中编译我的 C++ 项目时,我不断收到以下 2 个错误:
E1574: Static assertion failed with "Windows headers require the default
packing option. Changing this can lead to memory corruption. This diagnostic
can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined."
和
C2338: Windows headers require the default packing option. Changing this can
lead to memory corruption. This diagnostic can be disabled by building with
WINDOWS_IGNORE_PACKING_MISMATCH defined.
我认为问题一定出在我的 Visual Studio 设置中,导致该项目在我的另一台 PC 上编译正常,而我刚刚在这台 PC 上安装了 Visual Studio。
通过一些搜索,问题似乎源于 Windows 包的不匹配,但是在安装 Visual Studio 时,我尝试安装我看到的所有 C++ 和 Windows 10 模块。
此外,我只包含 windows.h
以便使用 ShellExecute()
,所以如果有更好的方法来使用 ShellExecute()
我对此持开放态度。谢谢!
最佳答案
正如上面提到的 1201ProgramAlarm,解决方案是禁用 /Zp
(结构打包)编译器选项。
关于c++ - 静态断言失败,返回 "Windows headers require the default packing option...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56570681/