简体   繁体   中英

ERROR Windows headers require the default packing option on winnt.h

I have an old C++ program I recovered to update and re-use it with Visual Studio 2019.

When I try to compile winnt.h , it gives the error:

Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnosis can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined

I saw this post Static assertion failed with "Windows headers require the default packing option..." and I already changed the packing option from 4bytes to default ( Project Settings > C/C++ > Code Generation > Struct Member Alignment (change to Default) ).

What am I missing? How can I solve it?

  1. Check if #pragma pack is used in the code. If you use #pragma pack , do not set Struct Member Alignment in the project configuration, because it will disturb the direct alignment of other code.

  2. Check whether your project platform settings are consistent with the property page settings.

图片

图片

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM