exiv2 icon indicating copy to clipboard operation
exiv2 copied to clipboard

Can we keep public headers C++11 compatible?

Open hassec opened this issue 3 years ago • 7 comments

While we have moved to using C++17 internally, I think we should try to investigate how painful it would be to keep the public headers C++11 compatible.

Some recent MRs for example introduced std::string_view into basicio.hpp. https://github.com/Exiv2/exiv2/blob/7ebf2a184e28bf638a39aa30ed3784c5035b668a/include/exiv2/basicio.hpp#L698

This is motivated by a report on the matrix channel by @aurelienpierre who stumbled over this when trying to compile darktable (C++11) with the latest master version of exiv2.

cc @piponazo @kevinbackhouse @kmilos @neheb @alexvanderberkel

hassec avatar Jul 01 '22 14:07 hassec

I don't have a strong opinion on this.

kevinbackhouse avatar Jul 01 '22 14:07 kevinbackhouse

Those string_views should just be auto. I'll write a PR.

neheb avatar Jul 01 '22 14:07 neheb

Me neither, but have some questions:

Any particular reason for @aurelienpierre not using 0.27-maintenance branch?

Also, might be an idea to plan a 0.27.6 release?

kmilos avatar Jul 01 '22 14:07 kmilos

@neheb before we change more, I'd suggest we create a test first that checks these headers compile with C++11 otherwise, changing something will just introduce more churn without any gain.

@kmilos that's the advice we gave on matrix. But in general, eventually main will hopefully become a released version, so we should be happy that someone is trying to build with the main branch and test things.

hassec avatar Jul 01 '22 14:07 hassec

Sounds good. I have no real way of testing my changes. Well, maybe building with darktable.

neheb avatar Jul 01 '22 22:07 neheb

Hi guys. I think we should be able to test that the exiv2 target is only using C++11 features.

At the moment we are setting the C++ standard globally for our project with:

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

I do not recall if this is propagated to the consumers of Exiv2 via the CMake configuration files which are deployed during the installation step. However it should be possible to indicate that exiv2 needs at least c++11 by using this cmake code:

target_compile_features(exiv2lib PUBLIC cxx_std_11)

This information will appear in the Exiv2 CMake files we provide to customers.

Then a consumer project including Exiv2 and using a C++11 compiler should complain if =>C++14 features are included. I have this dummy project for test those things:

https://github.com/piponazo/exiv2Consumer .

Let me know if I can help with this topic. We could move #2257 to a branch in the main exiv2 repository so that few of us can work in the same branch.

piponazo avatar Jul 03 '22 15:07 piponazo

I merged that PR. AFAIK, it should be fine now.

neheb avatar Jul 25 '22 03:07 neheb

This can be closed I think

neheb avatar Feb 20 '23 22:02 neheb