-
Notifications
You must be signed in to change notification settings - Fork 37
fixed: zlib version mismatch! [ZlibStreamError] #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
All I did was change the int32 to int |
|
I just ran into the same problem. The current code will fail on any LP64 OS (i.e. those where C I'm guessing this is old code that predates the C-based types like |
Integer types in zlib.h were not properly translated into Nim. Most seriously, `Ulong` and `Ulongf` (which are both `unsigned long`) were translated to `int32`, which is wrong on LP64 systems like macOS, iOS and I think 64-bit Linux too. This causes the Nim `ZStream` struct to be much shorter than the real `z_stream` (88 vs 120 bytes), and that causes the size comparison in the inflate/deflateInit functions to fail with Z_VERSION_ERROR, which is actually a good thing because if it kept going it would be smashing memory, since Nim didn't allocate enough space for its struct. I've fixed the types to the best of my knowledge, using the standard C-based types like `cint` and `culong`. The only iffy one is `ZOffT` which has a complicated conditional definition in C -- I think it's supposed to match `off_t`, whose size depends not on the ABI but on whether the filesystem supports 64-bit files... I made it a `clong` since most systems handle 64-bit files nowadays. Fixes nim-lang#23, nim-lang#39, nim-lang#53
AFAIK, this should be solved now that #60 is merged. If not, please comment and I'll reopen it. |
Uh oh!
There was an error while loading. Please reload this page.
I was working with zlib, and noticed that when I compiled to 64bit the library threw the error zlib version mismatch! [ZlibStreamError]. However, if I compiled to 32bit the library worked just fine. I discoverd that this is because of the use of in32 to I change the code, and now is working. I don't know how to do a PR so I'll just post the code
zip/zlib.nim :
The text was updated successfully, but these errors were encountered: