I'm writing C# bindings for a C library using unsafe code. I can't figure out how to represent a size_t that works in all cases:
System.[U]IntPtrcan't be used with fixed-sized buffer (which I need), because they are whitelisted to only work with a few primitive types.- Aliasing the type with
using Usize = System.Uint32/64with compile time directives works, but a) breaks the portability of the resulting binary between architectures and b) I'd have to add the using block to everywhere that used theUsizetype.
So, what is the correct way to write C bindings using size_t?