CnC_Remastered_Collection icon indicating copy to clipboard operation
CnC_Remastered_Collection copied to clipboard

Windows headers require the default packing option. Changing this can lead to memory corruption.

Open Life4gal opened this issue 5 years ago • 3 comments

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. : -)

Life4gal avatar Jun 06 '20 15:06 Life4gal

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

alexlk42 avatar Jun 06 '20 15:06 alexlk42

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

Resource\TiberianDawn.rc(10): fatal error RC1015: cannot open include file 'afxres.h'.

Done building project "TiberianDawn.vcxproj" -- FAILED. ------ Build started: Project: RedAlert, Configuration: Release Win32 ------ Resource\RedAlert.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?

Bast75 avatar Jun 12 '20 11:06 Bast75

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 https://github.com/electronicarts/CnC_Remastered_Collection/issues/36

alexlk42 avatar Jun 12 '20 13:06 alexlk42