静态断言失败,显示"Windows标头需要默认打包选项...". [英] Static assertion failed with "Windows headers require the default packing option..."

查看:1989
本文介绍了静态断言失败,显示"Windows标头需要默认打包选项...".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在Visual Studio中编译我的C ++项目时,我不断收到以下两个错误:

When I'm trying to compile my C++ project in Visual Studio, I keep getting the 2 following errors:

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.

I think the issue has to be something in my Visual Studio settings, cause the project compiles fine on my other PC, and I just installed Visual Studio on this PC.

通过进行一些搜索,看起来问题似乎源于Windows软件包的不匹配,但是在安装Visual Studio时,我尝试安装我看到的所有C ++和Windows 10模块.

From doing some searches look like the issue stems from a mismatch of Windows packages, however when installing Visual Studio I tried to install all the C++ and Windows 10 modules I saw.

此外,我只包括windows.h以便使用ShellExecute(),因此,如果有使用ShellExecute()的更好方法,我很乐意.谢谢!

Also, I'm only including windows.h in order to use ShellExecute(), so if there's a better way to use ShellExecute() I'm open to that. Thanks!

推荐答案

如上面提到的1201ProgramAlarm一样,解决方案是禁用/Zp(结构打包)编译器选项.

As 1201ProgramAlarm mentioned above, the solution was disabling the /Zp (structure packing) compiler option.

这篇关于静态断言失败,显示"Windows标头需要默认打包选项...".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆