When marshalling struct which contains a single char field from C++ to C# how the C# struct definition should look like?
[StructLayout(LayoutKind.Sequential, Size = 1), Serializable]
public struct SomeStruct
{
[MarshalAs(UnmanagedType.I1)]
public sbyte Field;
}
or
[StructLayout(LayoutKind.Sequential, Size = 1), Serializable]
public struct SomeStruct
{
[MarshalAs(UnmanagedType.U1)]
public byte Field;
}
I can't find a clear info about should it be a signed byte or not. (It is declared as 'char' in C++ struct definition)
UPD: Does It depends on whether C++ lib was build with GCC or VS (default compiler options)? If not, can I hope 'char' is signed on both GCC and VS (default compiler options)