My struct in C++ is the following
/* this structure contains the xfoil output parameters vs angle of attack */
typedef struct xfoil_outputdata_struct
{
double *pAlfa;
double *pCL;
double *pCM;
double *pCDi;
double *pCDo;
double *pCPmax;
long nEntries;
} XFOIL_OUTPUT_DATA;
/* Here are the function prototypes for XFoil */
__declspec(dllexport) XFOIL_OUTPUT_DATA *xfoilResults(); /* get output from xfoil */
I use XFoilResults to pull this structure back into C#
My DLL Imports statement is the following:
[DllImport("xfoilapi.dll")]
public static extern void xfoilResults();
Is this correct? I have no control over the C++ code. I just need to be able to pull the struct into C#. The C# struct I have so far is the following
[StructLayout(LayoutKind.Sequential)]
public struct xfoilResults
{
IntPtr pAlfa;
IntPtr pCL;
IntPtr pCM;
IntPtr pCDi;
IntPtr pCDo;
IntPtr pCPmax;
long nEntries;
}
How can I populate this C# structure with the data from the C++ code?
StructLayoutmust be on a class.This should do the trick: