Skip to content
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

Expose zlib constants for backwards compat #815

Merged
merged 5 commits into from
Nov 11, 2024

Conversation

Coeur
Copy link
Contributor

@Coeur Coeur commented Nov 1, 2024

Fix #747
Supersedes #750 (cc @brad0)

I re-did the PR to account for the recent refactor in 7df56f7

compat/ioapi.h Outdated Show resolved Hide resolved
mz_crypt.c Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@brad0
Copy link
Contributor

brad0 commented Nov 1, 2024

Thanks for taking this on.

@brad0
Copy link
Contributor

brad0 commented Nov 1, 2024

Also I noticed anything even remotely modern for zlib uses ZLIB_H instead of _ZLIB_H for the header guard, which is kinda strange as such guards usually have a prefix underscore.

madler/zlib@8e34b3a

@Coeur
Copy link
Contributor Author

Coeur commented Nov 1, 2024

Oh my, good catch.

I've now taken care of this in a2c1b2a

@brad0
Copy link
Contributor

brad0 commented Nov 3, 2024

Also regarding header guards..

unzip.h / zip.h
_ZLIBIOAPI_H

ioapi.h
ZLIBIOAPI64_H

@Coeur
Copy link
Contributor Author

Coeur commented Nov 3, 2024

Also regarding header guards..

Those aren't a big deal. And if we want to change it, it's not in the scope of this PR.

#ifndef _ZLIB_H
//#include "zlib.h"
#if !defined(_ZLIB_H) && !defined(ZLIB_H) && !defined(ZLIB_H_)
# if __has_include(<zlib-ng.h>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid __has_include is not available in MSVC?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it will only work if included into C++ file?

Copy link
Contributor Author

@Coeur Coeur Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__has_include is in VS 2017 15.3: https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance?view=msvc-170

Do we care about obsolete versions of Visual Studio which are more than 7 years old?

[edit]
Ah, maybe you meant that VS support is only for C++, as stated here:
https://stackoverflow.com/questions/71540280/make-has-include-portable-in-c

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

@Coeur Coeur Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmoinvaz can we merge this PR as it is, and deal with VS separately?
Otherwise, I guess, all what is needed is to add some nearly empty ioapi.cc file which just contains include "ioapi.h"? But I'm worried it could affect other platforms which don't expect C++ code.

@AannhTonn
Copy link

.

@nmoinvaz nmoinvaz added the compatibility Backwards compatibility label Nov 11, 2024
@nmoinvaz nmoinvaz merged commit 5221967 into zlib-ng:develop Nov 11, 2024
28 checks passed
@Coeur Coeur deleted the coeur/zlib branch November 11, 2024 21:07
@nmoinvaz
Copy link
Member

Since compat files moved to compat dir, not sure how to get cmake to use those when installing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Backwards compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backwards compatibility issue with minizip-ng
4 participants