Article ID: 136500
Article Last Modified on 10/16/2002
typedef struct // This struct goes in the C code
{
char c;
long l;
} PADDED_BY_COMPILER_STRUCT;
typedef struct // This struct goes in the IDL file
{
char c;
char pad[3]; // Add 3 bytes to align the next field on byte 4
long l;
} MANUALLY_PADDED_IDL_STRUCT;
Another alternative is to wrap the stub code generated by MIDL with
#pragma pack(1)Each time MIDL generates the stub code, you must insert #pragma pack statements into the server stub.
/* File created by MIDL compiler version 2.00.0102 */
/* at Fri Aug 18 13:48:23 1995
*/
//@@MIDL_FILE_HEADING( )
#pragma pack(1) // Added to fix MIDL pack problem
#include <string.h>
#include "bug.h"
... code generated by MIDL ...
#pragma pack() // Added to revert to default packing
Keywords: kbbug kbfix kbapi kbrpc kbnetwork kboswin2000fix KB136500