One option would be to manually set the packing options for the structure
in the header file.

#pragma pack(push)
#pragma pack(8) // Or something sensible.
typedef struct
{
// Whatever.
} STRUCT;
#pragma pack(pop)

But provided you stick to the same build options and always use the MSVC
compiler you should be safe without these
safeguards..

Daniel



>Hi,
>  I have an IOCP Socket project in where I am transferring data in a structure.
>The clients will always be XP, 2000 machines, and the server will be the
>same.
>
>I am sending a structure of information to the server application in one
>go, saving having to send each item 1 at a time.
>I am doing
>
> CopyMemory(&SocketBuff,&struct,sizeof(struct));
>then sending the buffer.
>
>and at the serial side, doing the reverse to receive the data. Everything
>works fine, but wondering with struct padding, would the size always be
the
>same on both client and server application?  I have one header file that
>both client and server load in, so will never get the fields the wrong way
>in the structure.
>
>If there is a problem with this, what is the bets way around it?
>
>Thanks
>Neil
>_______________________________________________
>msvc mailing list
>[email protected]
>See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
>subscription
>changes, and list archive.


___________________________________________________________

Book yourself something to look forward to in 2005.
Cheap flights - http://www.tiscali.co.uk/travel/flights/
Bargain holidays - http://www.tiscali.co.uk/travel/holidays/




_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
subscription changes, and list archive.

Reply via email to