-
Notifications
You must be signed in to change notification settings - Fork 282
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
Allow building Exiv2 0.27 with C++17 compiler #2743
base: 0.27-maintenance
Are you sure you want to change the base?
Allow building Exiv2 0.27 with C++17 compiler #2743
Conversation
@maksim-petukhov Hopefully the new release provides the solution that you need. |
@postscript-dev As I said in the first post, this doesn't change anything for existing users of library. It is still good old C++98 when they do not use C++17 compiler mode. And there are no users who used C++17 standard with 0.27.x because it wasn't possible prior that PR. I tried to use Exiv2 0.28, but unfortunately in my project I can't open files with non-ASCII paths using it (see my comment). If I can't use 0.28 I have to use 0.27.x, but I use C++17 and 0.27.x is not C++17-compatible. So here we are. |
this is an API change. I've seen libcxx fail with compilation as _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR is needed. |
@neheb I'm sorry, but how does it change the API? |
You’re redefining AutoPtr as unique_ptr. |
Yes, but I'm doing it only for C++17 compiler mode so no users are affected by this API change. This library cannot be used with C++17 now, so there is no API at all. |
@maksim-petukhov
To summarise, although your PR might provide a solution it will cause several maintenance issues moving forward. |
GCC (as of v13) doesn't prevent you from compiling 0.27.x as c++17 AFAIK, and Clang compiles by simply defining |
google says for MSVC, _HAS_AUTO_PTR_ETC=1 needs to be defined. These two changes need to be done with CMakeLists.txt , not by changing headers and whatnot. |
Not even, you can define on the command line when calling CMake (or from a build system of a project using exiv2) on a an as-needed basis, so no change to the 0.27 branch is required AFAICT... |
@neheb @kmilos These defines are required not only to build exiv2. You have to define them for you project too because exiv2 uses auto_ptr in its interface. This can be OK for some "Hello World"-like program but not really appropriate for production code. There are internal guidelines, there are tendencies for conformance with C++ standard and these compiler defines are not compatible with these things. We can see how other people do this:
Some of these libraries are not maintained AFAIK so you have to patch them. Having these necessary changes within the library itself is a more streamlined approach. This is the motivation behind my PR. |
Codecov Report
@@ Coverage Diff @@
## 0.27-maintenance #2743 +/- ##
=================================================
Coverage 58.81% 58.81%
=================================================
Files 149 149
Lines 24476 24476
Branches 12669 12669
=================================================
Hits 14395 14395
Misses 7209 7209
Partials 2872 2872
|
The only thing that is preventing this from happening is using
std::auto_ptr
. This PR introduces two compile definitionsEXV_NO_AUTO_PTR
(I looked atBOOST_NO_AUTO_PTR
for inspiration) andEXV_NO_AUTO_PTR_MOVE
which are defined only when compiling library with C++17 compiler flag. As far as I can tell there are no existing users of this library which are affected by this change: even using C++11 and C++14 compiler flag user will have the same behavior as before this PR,std::auto_ptr
will be used. Looks not really nice, I know, but I think it is OK to have this on maintenance branch. I tested this changes locally with MSVC 192, gcc 10.4 and clang from android sdk r25c.