The minizip API exposes 'long' and 'ulong' types which are not fixed width. Therefore it's impossible to bind and P/Invoke these in a cross platform way. Currently we only work on systems where sizeof (IntPtr) == sizeof (native long).
First: Should we fix this?
- Yes, ideally we should. If we don't fix it, maybe there should be a compile time make check to ensure sizeof (native long) == sizeof (native pointer).
Second: How should we fix it
- We can expose a nicer API which uses fixed width types.
- Or we can modify the existing minizip APIs to expose only fixed width sizes
The former is the least invasive but would make it confusing for people P/Invoking the native libs as there'd be two sets of APIs to choose from.
The latter would be better as there'd be a single set of working APIs which can be P/Invoked. However if we wanted to import a newer minizip we'd have a maintenance burden porting the changes to the newer minizip. Also we'd have to port every single usage of minizip in one go if we wanted to go with this approach. If it's P/Invoked elsewhere it'd just blow up as the existing P/Invoke declarations would no longer be compatible.
I suggest that we force uLong (the only long I could find on the API) to be 32bits on 64 bit systems.
It seems that the code in minizip assumes that uLong is actually 32 bits in a few places.