Odex
Odex
CC#
Created by Odex on 5/13/2024 in #help
How to marshall pointer to array inside struct
I have the following struct
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
public Rectangle* Recs;
public GlyphInfo* Glyphs;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
public Rectangle* Recs;
public GlyphInfo* Glyphs;
}
Here Recs and Glyphs are C like arrays iirc. I want to marshal them to managed ones but I get the following error
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
// Already tried [MarshalAs(UnmanagedType.ByValArray)]
public Rectangle[] Recs;
public GlyphInfo[] Glyphs;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe struct Font
{
public int BaseSize;
public int GlyphCount;
public int GlyphPadding;
public Texture Texture;
// Already tried [MarshalAs(UnmanagedType.ByValArray)]
public Rectangle[] Recs;
public GlyphInfo[] Glyphs;
}
Error SYSLIB1051 : The type 'MyNamespace.Font' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'font'.
Error SYSLIB1051 : The type 'MyNamespace.Font' is not supported by source-generated P/Invokes. The generated source will not handle marshalling of parameter 'font'.
I am using LibraryImport
17 replies