I am trying to learn how to write a wrapper around a DLL, and I hit a little road block. I have a structure declared as such:
[StructLayout(LayoutKind.Sequential)] unsafe struct SDL_Surface { public readonly UInt32 flags; public readonly SDL_PixelFormat* format; public readonly int w, h; public readonly int pitch; public void* pixels;
When I try to compile my project, it gives the above error.
But you will notice above, I have a pointer to another structure. I am trying to understand what is the difference between these two structures, which does one job and the other does not, but I'm not sure; they are both unsafe structures. They look like this:
[StructLayout(LayoutKind.Sequential)] unsafe struct SDL_PixelFormat { UInt32 format; SDL_Palette *palette; byte BitsPerPixel; byte BytesPerPixel; fixed byte padding [2]; UInt32 Rmask; UInt32 Gmask; UInt32 Bmask; UInt32 Amask; byte Rloss; byte Gloss; byte Bloss; byte Aloss; byte Rshift; byte Gshift; byte Bshift; byte Ashift; int refcount; SDL_PixelFormat *next; } unsafe internal delegate int SDL_blit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect); [StructLayout(LayoutKind.Sequential)] unsafe struct SDL_BlitMap { SDL_Surface* dst; int identity; SDL_blit blit; void* data; SDL_BlitInfo info; UInt32 dst_palette_version; UInt32 src_palette_version; } [StructLayout(LayoutKind.Sequential)] struct SDL_Rect { int x, y; int w, h; }
So what do I need to change to do this compilation?
I find the link to SDL_blit in SDL_BlitMap to be causing the problem. I declared this a delegate; is there anything else i should declare it? It is defined like this, in C:
typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, struct SDL_Surface * dst, SDL_Rect * dstrect);
source share