微软指定编译器不做字节填充方法

一、压栈

PshPack1.h头文件

#if ! (defined(lint) || defined(RC_INVOKED))

#if ( _MSC_VER >= 800 && !defined(_M_I86)) || defined(_PUSHPOP_SUPPORTED)

#pragma warning(disable:4103)

#if !(defined( MIDL_PASS )) || defined( __midl )

#pragma pack(push,1)

#else

#pragma pack(1)

#endif

#else

#pragma pack(1)

#endif

#endif

PshPack2.h头文件

#if ! (defined(lint) || defined(RC_INVOKED))

#if ( _MSC_VER >= 800 && !defined(_M_I86)) || defined(_PUSHPOP_SUPPORTED)

#pragma warning(disable:4103)

#if !(defined( MIDL_PASS )) || defined( __midl )

#pragma pack(push,2)

#else

#pragma pack(8)

#endif

#else

#pragma pack(8)

#endif

#endif

二、出栈

PopPack.h头文件

#if ! (defined(lint) || defined(RC_INVOKED))

#if ( _MSC_VER >= 800 && !defined(_M_I86)) || defined(_PUSHPOP_SUPPORTED)

#pragma warning(disable:4103)

#if !(defined( MIDL_PASS )) || defined( __midl )

#pragma pack(pop)

#else

#pragma pack()

#endif

#else

#pragma pack()

#endif

#endif


你可能感兴趣的:(微软指定编译器不做字节填充方法)