【发布时间】:2019-06-12 21:35:34
【问题描述】:
当我尝试在 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 模块。
另外,为了使用ShellExecute(),我只包括windows.h,所以如果有更好的方法来使用ShellExecute(),我愿意接受。谢谢!
【问题讨论】:
-
不要使用
/Zp(结构打包)编译器选项。 -
@1201ProgramAlarm 谢谢这似乎有效!这种方法有什么缺点吗?
-
真正的问题是你为什么要在第一位添加
/Zp? -
@RichardCritten 超级具体,Adobe After Effects Plugin SDK,Struct Member Alignment 设置为
4 Byte (/Zp4) -
@JustinTaylor -- 那么无论谁把那个包裹放在一起,都可悲的是没有注意。有一些方法可以在源代码本身中设置自定义结构的打包(例如
pragma pack),而不是通过通用编译器开关来搞砸其他结构。
标签: c++ windows visual-studio header-files