P/Inkoke struct member alignment

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi,

What is the struct member aligment of a C# program? Are there any issues
with P/Invoke when passing structs to 3rd party C dlls?

Thanks
 
You should use the StructLayout attributes on your structs if you are
passing back and forth between C dll's and a managed application. The
StructLayout will allow you to set up the unmanaged size of the structure,
packing, character sets for strings, whether the layout should be sequential
(field order), or allow you to set offsets explicitly. Then for each field
(if using explicit), you can set the FieldOffset. This is how you might
attempt to support unions and other such structures.
 
Back
Top