The information in this article applies to:
SYMPTOMSThe default packing (alignment) for structures in Windows NT is 8 bytes. This setting is the default for projects created using the Visual Workbench. Programs built with other packing build without error, but the resulting executable may produce run-time errors. These errors include incorrect data, error return codes from Win32 APIs, or program failure. On RISC platforms, such as MIPS and Alpha, doubles and long ints that are not 8-byte-aligned cause alignment faults. CAUSEThe default packing on Windows NT is 8-byte packing. This packing is used both for efficiency reasons and for portability (some RISC processors allow only 8-byte packing). Because the operating system is expecting data packed on 8-byte boundaries, it may incorrectly process structures passed from programs that were not packed on 8-byte boundaries. Not all programs exhibit this behavior. One example that does give problems with a different kind of packing is shown in the "MORE INFORMATION" section. RESOLUTIONIf a program builds without errors or warnings but does not run correctly, one thing to check is that all modules are compiled with /Zp8 (or no /Zp switch at all). MORE INFORMATION
Many MS-DOS and Windows programs are built with 1- or 2-byte packing. Old
makefiles may have a /Zp1 or /Zp2 setting included. When porting programs
with Win32, this setting should be changed. In addition, check for a /Zp
setting in the CL environment variable in the AUTOEXEC.BAT file. This
setting overrides the setting in the Visual Workbench or in a makefile.
REFERENCES
For more information on alignment, see the "Programming Techniques" book
included with the Visual C++, 32-bit Edition, documentation set.
Additional query words: 8.00 9.00
Keywords : kbCompiler kbVC100 kbVC200 kbVC210 kbVC220 kbVC400 kbVC410 kbVC420 kbVC500 kbVC600 |
Last Reviewed: July 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |