Windows headers require the default packing option

winnt.h // Much of the Windows SDK assumes the default packing of structs. #if !defined(WINDOWS_IGNORE_PACKING_MISMATCH) && !defined(__midl) && !defined(MIDL_PASS) && !defin...

@Life4gal

winnt.h
// Much of the Windows SDK assumes the default packing of structs. #if !defined(WINDOWS_IGNORE_PACKING_MISMATCH) && !defined(__midl) && !defined(MIDL_PASS) && !defined(SORTPP_PASS) && !defined(RC_INVOKED) #if defined(__cplusplus) && (_MSC_VER >= 1600) static_assert(__alignof(LARGE_INTEGER) == 8, "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."); #elif _MSC_VER >= 1300 #pragma warning(push) #pragma warning(disable: 4116) C_ASSERT(TYPE_ALIGNMENT(LARGE_INTEGER) == 8); #pragma warning(pop) #endif #endif

«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’

Project Settings > C/C++ > Code Generation > Struct Member Alignment (change to Default)

I hope it works for you. : -)

@alexlk42

In my experience you are better off defining WINDOWS_IGNORE_PACKING_MISMATCH instead of setting struct member alignment to default. The altered struct alignment was causing my dlls to crash the game. Preserving the original struct alignment resulted in dlls that were compatible with the game. My fork shows how to do this if you are interested https://github.com/alexlk42/CnC_Remastered_Collection

@Bast75

Hi Alexlk42,
I downloaded your version. But when i build, it got the following error:

ResourceTiberianDawn.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.

Done building project «TiberianDawn.vcxproj» — FAILED.
—— Build started: Project: RedAlert, Configuration: Release Win32 ——
ResourceRedAlert.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.

Done building project «RedAlert.vcxproj» — FAILED.
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

afxres.h is indeed missing.
Any ideas?

@alexlk42

I believe that means you need to download the build tools, which contain the needed headers.

Downloaded v142 build tools (C++ MFC) via Visual Studio Installer.

This is discussed here #36

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?

Remy Lebeau's user avatar

Remy Lebeau

535k30 gold badges444 silver badges750 bronze badges

asked Jan 20, 2021 at 14:31

Lluís's user avatar

2

  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.

image

image

Remy Lebeau's user avatar

Remy Lebeau

535k30 gold badges444 silver badges750 bronze badges

answered Jan 21, 2021 at 1:51

Barrnet Chou's user avatar

Barrnet ChouBarrnet Chou

1,6921 gold badge3 silver badges7 bronze badges

3

Hey guys!

I’ve been working on an AE plugin, and I had a really strange problem today. I’ve never had a problem building/debugging the plugin, but today when I tried to debug in Visual Studio I got this error message:

——

Severity Code Description Project File Line Suppression State
Error (active) 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.» Skeleton C:Program Files (x86)Windows Kits10Include10.0.18362.0umwinnt.h 2482

——

After some googling, I found this stack overflow post and tried following their advice but it didn’t help. I also tried defining «WINDOWS_IGNORE_PACKING_MISMATCH» in C/C++ > Preprocessor > Preprocessor Definitions but that didn’t do anything either.

Does anyone know why this would’ve randomly started happening? Did I perhaps adjust a setting in my IDE without realizing it…? Any and all ideas would be greatly appreciated.

Thanks!

Содержание

  1. Windows headers require the default packing option. Changing this can lead to memory corruption. #34
  2. Comments
  3. Life4gal commented Jun 6, 2020 •
  4. alexlk42 commented Jun 6, 2020
  5. Bast75 commented Jun 12, 2020
  6. alexlk42 commented Jun 12, 2020
  7. mhook build failure #8748
  8. Comments
  9. BenKey commented Oct 26, 2019
  10. LilyWangL commented Oct 28, 2019
  11. Christsnatcher commented Feb 12, 2020 •
  12. Pospelove commented Feb 27, 2020
  13. BenKey commented Feb 27, 2020
  14. Christsnatcher commented Feb 27, 2020
  15. The Powder Toy
  16. Error C2338 when compiling clean source.
  17. EDIT:
  18. 4.22.1 #10
  19. Comments
  20. uran commented May 10, 2019 •
  21. RVillani commented Jan 15, 2020
  22. Windows headers require the default packing option changing this can lead to memory corruption

«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’

Project Settings > C/C++ > Code Generation > Struct Member Alignment (change to Default)

The text was updated successfully, but these errors were encountered:

In my experience you are better off defining WINDOWS_IGNORE_PACKING_MISMATCH instead of setting struct member alignment to default. The altered struct alignment was causing my dlls to crash the game. Preserving the original struct alignment resulted in dlls that were compatible with the game. My fork shows how to do this if you are interested https://github.com/alexlk42/CnC_Remastered_Collection

Hi Alexlk42,
I downloaded your version. But when i build, it got the following error:

ResourceTiberianDawn.rc(10): fatal error RC1015: cannot open include file ‘afxres.h’.

afxres.h is indeed missing.
Any ideas?

I believe that means you need to download the build tools, which contain the needed headers.

Downloaded v142 build tools (C++ MFC) via Visual Studio Installer.

Источник

mhook build failure #8748

Host Environment

To Reproduce

Install mhook as follows.

Failure logs

Additional context

The problem occurs in the following code block from winnt.h.

The C_ASSERT fails because of the following code in disasm-libcpu.h.

I think reversing the order of the lines might suffice to fix the build error but I am not certain.

The text was updated successfully, but these errors were encountered:

Thanks for posting this issue. This issue belongs to the Windows platform. This is C2118 error with Windows Kits 10.0.18362.0 in winnt.h. Mhook:x64-windows can install successfully on Windows SDK Version 10.0.17763.0. You can remove Windows SDK Version 10.0.18362.0 and install Windows SDK Version 10.0.17763.0.

Just wanted to mention that it’s still impossible to build mhook. And being forced to uninstall the current SDK isn’t something I would call a valid solution, sorry. I would be very grateful if this issue could be fixed properly.

Ok, it suffices to replace «C:Program Files (x86)Windows Kits10Include10.0.18362.0umwinnt.h» with «C:Program Files (x86)Windows Kits10Include10.0.17763.0umwinnt.h» just for the time you build the mhook package, that’s something I can live with.

It also can be reproduced with x86-windows triplet.

I found the blocked by upstream conclusion to be unsatisfactory. I found a solution in my fork but I did not do a pull request because of the aforementioned blocked by upstream conclusion. It turns out that all you need to do is define the preprocessor symbol WINDOWS_IGNORE_PACKING_MISMATCH while building the project.

Should I do a pull request?

I would definitely appreciate a proper solution for this issue, thank you very much!

Источник

The Powder Toy

Error C2338 when compiling clean source.

f31ae39a6096de825ab1d2cbb5a8d0af?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

I get an error when compiling a clean source from a premade VS project for TPT++ after following all of your instructions on the wiki page:

C:Program Files (x86)Windows Kits10Include10.0.18362.0umwinnt.h(2482,40): error 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.

It terminates the build process. Anything I can do to stop it?

(I originally posted this in the development section, before I realised I should have posted it here.)

While I was compiling, I came across another error:

C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.23.28105includextgmath.h(22,47): warning C4244: ‘=’: conversion from ‘double’ to ‘int’, possible loss of data (compiling source file srcsimulationelementsSPRK.cpp)

SOLUTION:

Fix error C4244: this seemed to show up even if ‘treat warnings as errors’ was set to ‘No’. I found it worked if I set ‘warning level’ to ‘None’.

5382379b332afd251afa0d45a23e57a2?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

There’s a few things you can try:

Disable the option «Treat Warnings As Errors», as mentioned on the wiki page

Define WINDOWS_IGNORE_PACKING_MISMATCH under C++ > Preprocessor > Preprocessor definitions
(the error message seems to say it will work)

I also googled it, and it said turning off /Zp fixes it. I don’t remember this setting being set, I’ve actually never heard of it before. But if you can find it and turn it off, it might fix it. Google says this option is located at C/C++ > Code Generation > Struct Member Alignment

f31ae39a6096de825ab1d2cbb5a8d0af?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

OK, thanks a lot! I have already disabled the ‘treat warnings as errors’ option, but I’ll try to find /Zp and see if that fixes it. If it doesn’t, I’ll define the WINDOWS_IGNORE_PACKING_MISMATCH thing.

EDIT:

Right, so setting /Zp to 16 bytes (if you have that option) got past that problem, now I have a new one:

C:Program Files (x86)Microsoft Visual Studio2019CommunityVCToolsMSVC14.23.28105includextgmath.h(22,47): warning C4244: ‘=’: conversion from ‘double’ to ‘int’, possible loss of data (compiling source file srcsimulationelementsSPRK.cpp)

It appeared for SOAP (conversion from ‘double’ to ‘float’), and Gravity (‘double’ to ‘float’) as well.

5382379b332afd251afa0d45a23e57a2?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

@biran4454 (View Post)
That error is definitely caused by the option «Treat Warnings As Errors» being on, I’ve seen it before. It’s a visual studio bug. The error is in xtgmath.h, which is a standard include file and isn’t supposed to error.

f31ae39a6096de825ab1d2cbb5a8d0af?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

‘treat warnings as errors’ doesn’t fix it (I’ve tried all the options) and ‘turn off all warnings’ on ‘warning level’ (/W) doesn’t either. Also, when I have /Zp set to 16, which previously fixed the ‘default packing option’ it still brings up that error.

5382379b332afd251afa0d45a23e57a2?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

f31ae39a6096de825ab1d2cbb5a8d0af?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

I have pasted 3 builds with different property combinations at https://bpaste.net/show/G7PW4.

5382379b332afd251afa0d45a23e57a2?s=40&d=https%3A%2F%2Fpowdertoy.co.uk%2FDesign%2FImages%2FAvatar

@biran4454 (View Post)
Don’t set strict member alignment to 16, it should be default.

I see that all 3 of your builds still say this, and this is the actual error:
1>C:Program Files (x86)Windows Kits10Include10.0.18362.0umwinnt.h(2482,40): error 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. (compiling source file srcPowderToySDL.cpp)

If setting struct packing to default doesn’t fix it, try defining WINDOWS_IGNORE_PACKING_MISMATCH.

Источник

4.22.1 #10

Hello, Rodrigo!
Thanks a lot!
But, project with ue4Duino plugin 4.22.0 does not open in UE 4.22.1 (
Plugin rebuild result is:
[1/2] Module.UE4Duino.cpp
D:Program Files (x86)Windows Kits10include10.0.18362.0umwinnt.h(2482): error 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.
[2/2] Module.UE4Duino.gen.cpp
D:Program Files (x86)Windows Kits10include10.0.18362.0umwinnt.h(2482): error 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.
Took 7.2380772s to run UnrealBuildTool.exe, ExitCode=5
ERROR: UnrealBuildTool failed. See log for more details. (C:UsersuranAppDataRoamingUnreal EngineAutomationToolLogsF+UE_4.22UBT-UE4Game-Win32-Development.txt)
(see C:UsersuranAppDataRoamingUnreal EngineAutomationToolLogsF+UE_4.22Log.txt for full exception trace)
AutomationTool exiting with ExitCode=5 (5)
BUILD FAILED (((((((
BUT! Rebuild with error plugin worked now! ))))))

The text was updated successfully, but these errors were encountered:

Sorry I took so long to learn about Issues on Github. I’ve never really explored the site. :/
I’ll close this because there’re already released binaries and code for UE 4.22 up to 4.24

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

I have tried both 2017 and 2019 visual studio and installed both the C++ as per suggestion in the guide secion

When I go to build, I get thousands of these errors for each file that it wants to write out for the build but I can’t find anything in google to show what it’s complaining about

The only thing I have updated is the unit section to increase HP of mammoth tank from 600 to 800

Severity Code Description Project File Line Suppression State
Error 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. (compiling source file win32libWSA.CPP) TiberianDawn C:Program Files (x86)Windows Kits10Include10.0.19041.0umwinnt.h 2496

93c63b0d95347904bcb1a4c723a8fde8b4ac77f0

589324d5ba6c3308f8dc867f04c5f93a3b7a4abc

9e098aa77618c241acfd913d5ff78c8e18ccb910

I haven’t had a chance to look at the source code project yet but maybe this will help disable the warning.

Struct Member Alignment should be set to default, but changing this might make the build fail in a big way if it relied on a specific alignment.

589324d5ba6c3308f8dc867f04c5f93a3b7a4abc

I haven’t had a chance to look at the source code project yet but maybe this will help disable the warning.

Struct Member Alignment should be set to default, but changing this might make the build fail in a big way if it relied on a specific alignment.

I found that Preprocessor sub category, but it doesn’t allow for adding more entries in?

I did the last part Struct Member Alignment and made it now default

I now get only this one single error

What do I do now with this one?

Severity Code Description Project File Line Suppression State
Error RC1015 cannot open include file ‘afxres.h’. TiberianDawn C:tempC&C RemasteredsteamappscommonCnCRemasteredSOURCECODETiberianDawnResourceTiberianDawn.rc 10

9e098aa77618c241acfd913d5ff78c8e18ccb910

I found that Preprocessor sub category, but it doesn’t allow for adding more entries in?

You need to click on the line next to it, a drop down arrow should appear. You can click on that to edit the entries. Or you can just copy and past that line into the box.

If you like, send me a friend request and we can chat more over PM because then I can send you screenshots easily.

Severity Code Description Project File Line Suppression State
Error RC1015 cannot open include file ‘afxres.h’. TiberianDawn C:tempC&C RemasteredsteamappscommonCnCRemasteredSOURCECODETiberianDawnResourceTiberianDawn.rc 10

That error is showing that you are missing a c/c++ header file. The file is ‘afxres.h’ which is part of MFC (Microsoft Foundation Class Library). You can get these files by installing them through Visual Studio.

To install them type MFC into the search box at the top of VS’s window and then choose the «Install c++ XX.XX MFC for build tools XXX (x86 and x64)»

feb62f5e4372ef0af152ed35d952e9d0d1d5cc49

9e098aa77618c241acfd913d5ff78c8e18ccb910

as for a sub categroy for modding help, well there is the workshop discussion already 😉

589324d5ba6c3308f8dc867f04c5f93a3b7a4abc

I found that Preprocessor sub category, but it doesn’t allow for adding more entries in?

You need to click on the line next to it, a drop down arrow should appear. You can click on that to edit the entries. Or you can just copy and past that line into the box.

If you like, send me a friend request and we can chat more over PM because then I can send you screenshots easily.

Severity Code Description Project File Line Suppression State
Error RC1015 cannot open include file ‘afxres.h’. TiberianDawn C:tempC&C RemasteredsteamappscommonCnCRemasteredSOURCECODETiberianDawnResourceTiberianDawn.rc 10

That error is showing that you are missing a c/c++ header file. The file is ‘afxres.h’ which is part of MFC (Microsoft Foundation Class Library). You can get these files by installing them through Visual Studio.

To install them type MFC into the search box at the top of VS’s window and then choose the «Install c++ XX.XX MFC for build tools XXX (x86 and x64)»

Yup you right
I had to trial and error with each one until it worked
So in the end I have this many now installed to get it to compile mod.. geez why don’t they list these in the requirements so I don’t have to bug you guys.

But after try run the mod, it crashes straight away when try to launch.. ugh maybe I need to go back and try VS 2017 again if 2019 doesn’t fit

C++ 2019 Redistributable Update
C++ ATL for latest v142 build tools (x86 & x64)
C++ MFC for latest v142 build tools (x86 & x64)
C++/CLI support for v142 build tools (14.26)
C++ Clang-cl for v142 build tools (x64/x86)
C++ Clang Compiler for Windows (10.0.0)
C++ 2019 Redistributable MSMs
C++ ATL for v141 build tools (x86 & x64)
C++ MFC for v141 build tools (x86 & x64)
C++ v14.20 ATL for v142 build tools (x86 & x64)
C++ v14.20 MFC for v142 build tools (x86 & x64)
C++ v14.21 ATL for v142 build tools (x86 & x64)
C++ v14.21 MFC for v142 build tools (x86 & x64)
C++ v14.22 ATL for v142 build tools (x86 & x64)
C++ v14.22 MFC for v142 build tools (x86 & x64)
C++ v14.23 ATL for v142 build tools (x86 & x64)
C++ v14.23 MFC for v142 build tools (x86 & x64)
C++ v14.24 ATL for v142 build tools (x86 & x64)
C++ v14.24 MFC for v142 build tools (x86 & x64)
C++ v14.25 ATL for v142 build tools (x86 & x64)
C++ v14.25 MFC for v142 build tools (x86 & x64)

9e098aa77618c241acfd913d5ff78c8e18ccb910

You need to click on the line next to it, a drop down arrow should appear. You can click on that to edit the entries. Or you can just copy and past that line into the box.

If you like, send me a friend request and we can chat more over PM because then I can send you screenshots easily.

That error is showing that you are missing a c/c++ header file. The file is ‘afxres.h’ which is part of MFC (Microsoft Foundation Class Library). You can get these files by installing them through Visual Studio.

To install them type MFC into the search box at the top of VS’s window and then choose the «Install c++ XX.XX MFC for build tools XXX (x86 and x64)»

Yup you right
I had to trial and error with each one until it worked
So in the end I have this many now installed to get it to compile mod.. geez why don’t they list these in the requirements so I don’t have to bug you guys.

But after try run the mod, it crashes straight away when try to launch.. ugh maybe I need to go back and try VS 2017 again if 2019 doesn’t fit

C++ 2019 Redistributable Update
C++ ATL for latest v142 build tools (x86 & x64)
C++ MFC for latest v142 build tools (x86 & x64)
C++/CLI support for v142 build tools (14.26)
C++ Clang-cl for v142 build tools (x64/x86)
C++ Clang Compiler for Windows (10.0.0)
C++ 2019 Redistributable MSMs
C++ ATL for v141 build tools (x86 & x64)
C++ MFC for v141 build tools (x86 & x64)
C++ v14.20 ATL for v142 build tools (x86 & x64)
C++ v14.20 MFC for v142 build tools (x86 & x64)
C++ v14.21 ATL for v142 build tools (x86 & x64)
C++ v14.21 MFC for v142 build tools (x86 & x64)
C++ v14.22 ATL for v142 build tools (x86 & x64)
C++ v14.22 MFC for v142 build tools (x86 & x64)
C++ v14.23 ATL for v142 build tools (x86 & x64)
C++ v14.23 MFC for v142 build tools (x86 & x64)
C++ v14.24 ATL for v142 build tools (x86 & x64)
C++ v14.24 MFC for v142 build tools (x86 & x64)
C++ v14.25 ATL for v142 build tools (x86 & x64)
C++ v14.25 MFC for v142 build tools (x86 & x64)

a76978f44d82e3c9a4da8492af22fe92c10c0594

I’ve been trying to use VS 2017 community and having similar issues. The biggest one has been that no matter what I install, VS can’t see added libraries, so I’m having to add paths manually.
My lessons have been
If «stdio.h» or any other «st»andard class are missing, the system is either missing C++ (the «Windows SDK») entirely, or Visual Studio can’t find it.
If «afxres.h» is missing, the system is either missing MFC (Microsoft Foundation Class) or visual Studio can’t find it.

Ultimately, my checklist is as follows:

It now compiles and runs. Haven’t tried changing anything yet.

Per another thread, I also tried installing Windows SDK 8.1, but I’m not currently using it; doesn’t seem to have had any effect.

589324d5ba6c3308f8dc867f04c5f93a3b7a4abc

Yup you right
I had to trial and error with each one until it worked
So in the end I have this many now installed to get it to compile mod.. geez why don’t they list these in the requirements so I don’t have to bug you guys.

But after try run the mod, it crashes straight away when try to launch.. ugh maybe I need to go back and try VS 2017 again if 2019 doesn’t fit

C++ 2019 Redistributable Update
C++ ATL for latest v142 build tools (x86 & x64)
C++ MFC for latest v142 build tools (x86 & x64)
C++/CLI support for v142 build tools (14.26)
C++ Clang-cl for v142 build tools (x64/x86)
C++ Clang Compiler for Windows (10.0.0)
C++ 2019 Redistributable MSMs
C++ ATL for v141 build tools (x86 & x64)
C++ MFC for v141 build tools (x86 & x64)
C++ v14.20 ATL for v142 build tools (x86 & x64)
C++ v14.20 MFC for v142 build tools (x86 & x64)
C++ v14.21 ATL for v142 build tools (x86 & x64)
C++ v14.21 MFC for v142 build tools (x86 & x64)
C++ v14.22 ATL for v142 build tools (x86 & x64)
C++ v14.22 MFC for v142 build tools (x86 & x64)
C++ v14.23 ATL for v142 build tools (x86 & x64)
C++ v14.23 MFC for v142 build tools (x86 & x64)
C++ v14.24 ATL for v142 build tools (x86 & x64)
C++ v14.24 MFC for v142 build tools (x86 & x64)
C++ v14.25 ATL for v142 build tools (x86 & x64)
C++ v14.25 MFC for v142 build tools (x86 & x64)

Okay well you’re half way there if its at least compiling. I think the crash during running the mod might have to do with the «Struct Member Alignment» being changed. Can’t say for certain though. I’ll compile the source code tonight and let you know if I come accross the same problems and then we can work through it together.

Thanks Josh,
can confirm that once change the Struct Member Allgnment back to 1zip, the mod works in game

9e098aa77618c241acfd913d5ff78c8e18ccb910

Okay well you’re half way there if its at least compiling. I think the crash during running the mod might have to do with the «Struct Member Alignment» being changed. Can’t say for certain though. I’ll compile the source code tonight and let you know if I come accross the same problems and then we can work through it together.

Thanks Josh,
can confirm that once change the Struct Member Allgnment back to 1zip, the mod works in game

Источник

Ouh hi. Nice. Thanks for the response.
Let’s dig into it.

A couple more details if that is a very uncommon error.
I open: openttd_vs142.sln

Then I go: Build -> Build Solution (not build openttd? right? Either way, the result is identical)

And I spare you the whole output as it literally(!) is:

Severity Code Description Project File Line Suppression State
Error 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. (compiling source file ..srcdate.cpp) openttd G:Windows Kits10Include10.0.18362.0umwinnt.h 2482

80 times over and over again. Files: date.cpp, console.cpp, console_cmds.cpp, …

The only more or less kinda related stuff I found to this topic was:
https://stackoverflow.com/questions/293 … ck-warning
https://stackoverflow.com/questions/565 … ing-option

Regarding the second link, when I head to Project -> Properties -> C/C++ -> Command Line in «Additional Options» is: «/J /Zc:throwingNew /std:c++latest «.
However, removing ‘/Zc:throwingNew’ didn’t change any of the observed behavior. As I never use an IDE I am really digging in the dark and was hoping that someone has a direct solution to it.

Anyways. Thanks a lot for the help!

p.s. Clicking the error message leads to:
winnt.h

Code: Select all

2482 static_assert(__alignof(LARGE_INTEGER) == 8, "Windows headers require the default packing option. Changing this can lead to memory corruption."
2483    " This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined.");

p.p.s The only thing bothering me is: In the tutorial there is stated:

Set the build mode to Release in Build > Configuration manager > Active solution configuration. You can now compile.

There was no «Release» mode in the menu? So I manually added it? But that doesn’t feel right?

Когда я пытаюсь скомпилировать свой проект C++ в Visual Studio, я продолжаю получать 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, потому что проект отлично компилируется на моем другом компьютере, и я только что установил Visual Studio на этот компьютер.

Судя по некоторым поискам, проблема связана с несоответствием пакетов Windows, однако при установке Visual Studio я попытался установить все модули C++ и Windows 10, которые я видел.

Кроме того, я включаю windows.h только для того, чтобы использовать ShellExecute(), поэтому, если есть лучший способ использовать ShellExecute(), я открыт для этого. Спасибо!


code4days, 12 июня 2019 г., 23:35

8

15 711

1


Ответ:

Решено

Как упоминалось выше в 1201ProgramAlarm, решение заключалось в отключении опции компилятора /Zp (упаковка структуры).


code4days, 30 сентября 2019 г., 20:07

Интересные вопросы для изучения

Понравилась статья? Поделить с друзьями:
  • Windows home server 2011 vs windows home server 2011
  • Windows hdl image install program for ps2
  • Windows hd color что это такое
  • Windows hd color стоит ли включать
  • Windows home server 2011 server backup