I have a C++ SDK where I'm passing information as a struct to a C# CLI wrapper.
The C++ struct is as follows:
typedef struct SDK_API tag_PDP_SystemInfo { char siteName[MAX_TITLE_LENGTH + 1]; UINT32 cameraCount; int sensorCount; int channelId; CameraInfo cameraInfo[MAX_CAMERA_COUNTS]; } NativeSystemInfo;
And my equivalent struct in my CLI code is:
[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Ansi)] public value struct SystemInfo { public: [MarshalAsAttribute(System::Runtime::InteropServices::UnmanagedType::ByValTStr, SizeConst = 32)] String^ SiteName; [MarshalAsAttribute(System::Runtime::InteropServices::UnmanagedType::U4)] UINT32 CameraCount; int SensorCount; int ChannelId; [MarshalAsAttribute(System::Runtime::InteropServices::UnmanagedType::ByValArray, ArraySubType = System::Runtime::InteropServices::UnmanagedType::LPStruct, SizeConst=36)] array<CameraInfo>^ CameraInfo; };
Now my C++ code has a function that returns a struct like so:
NativeSystemInfo MySdk::GetSystemInfo() { return m_systemInfo; }m_systemInfo is of type NativeSystemInfo
In my CLI code I am calling the C++ function like so:
SystemInfo MySDKCLI::GetSystemInfo() { SystemInfo info; info = m_pMySdk->GetSystemInfo(); <--I get an Error in the '=' return info; }
I get the following error in the equals sign:
nooperator= matches these operands
operand types are MySDKCLIWrapper::SystemInfo=MySDKNative::NativeSystemInfo.
How do I pass the contents of the struct from the C++ to the CLI??