----- Original Message -----
Sent: Monday, November 18, 2002 3:32 PM
Subject: [DUG]: Sending a record to a C++ DLL

Hi all,
 
how do I determine which alignment to choose for a record that will be sent to a DLL compiled from C++ ? I have the source code for a test app that uses the DLL but I don't know enough of C++ to work out how to send a record to it. Here is a typical structure:
 
typedef struct EscCoordinateTag
{
 short Degree;
 short Minute;
 float Second;
} ESC_COORDINATE, *LPESC_COORDINATE;
Some structures contain other structure types also.
From what I understand of structure alignment, it only pads the structure when a member would be placed somewhere that isn't an even multiple of its own size, or the alignment value whichever is smaller.  So that structure should have offsets 0, 2 and 4 for Degree, Minute and Second respectively and a size of 8 bytes.
 
Assuming structure alignment is 4:
 
struct SExample
{
  short foo;
  int bar;
};
 
...will have a size of 8 bytes, with offsets of 0 and 4 for foo and bar respectively.
 
Hope this helps.
 
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur."

Reply via email to