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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top