When Windows header files need to adjust structure packing, they use the <pshpackN.h>
and <poppack.h>
header files. But why bother? Why not just issue the #pragma pack(push, N)
and #pragma pack(pop)
directly?
The #pragma pack
directive is a Microsoft compiler extension. It is not part of the C or C++ standard. The <pshpackN.h>
and <poppack.h>
headers are used so that compiler vendors can provide substitute headers which generate directives that work for their compilers.
For example, here is one example of a replacement header file that records the structure packing stack in preprocessor symbols.
Related reading: What are anonymous structs, and more importantly, how do I tell windows.h
to stop using them?
0 comments
Be the first to start the discussion.