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

basic conversion to C++20 #2645

Merged
merged 15 commits into from
Jan 24, 2025
Merged

basic conversion to C++20 #2645

merged 15 commits into from
Jan 24, 2025

Conversation

neheb
Copy link
Collaborator

@neheb neheb commented Jun 5, 2023

No description provided.

@ghost
Copy link

ghost commented Jun 5, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@codecov
Copy link

codecov bot commented Jun 5, 2023

Codecov Report

Attention: Patch coverage is 67.44186% with 28 lines in your changes missing coverage. Please review.

Project coverage is 64.68%. Comparing base (99c307f) to head (8adbda4).

Files with missing lines Patch % Lines
src/epsimage.cpp 0.00% 17 Missing ⚠️
src/sonymn_int.cpp 73.68% 0 Missing and 5 partials ⚠️
src/pentaxmn_int.cpp 0.00% 0 Missing and 4 partials ⚠️
src/bmffimage.cpp 0.00% 0 Missing and 1 partial ⚠️
src/tiffcomposite_int.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2645   +/-   ##
=======================================
  Coverage   64.67%   64.68%           
=======================================
  Files         104      104           
  Lines       22189    22195    +6     
  Branches    10854    10853    -1     
=======================================
+ Hits        14351    14357    +6     
  Misses       5598     5598           
  Partials     2240     2240           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@neheb neheb force-pushed the h branch 3 times, most recently from e68ae8a to 4cddaa6 Compare June 6, 2023 11:20
@neheb
Copy link
Collaborator Author

neheb commented Jun 7, 2023

Hrm I’m unsure of this PR. Compiler minimums have to increase for everything.

@neheb neheb force-pushed the h branch 2 times, most recently from 011b5e9 to 84e45a3 Compare June 30, 2023 10:58
@mandree
Copy link
Contributor

mandree commented Jul 1, 2023

Hrm I’m unsure of this PR. Compiler minimums have to increase for everything.

For library code it is usually good to use newer standards only in the implementation, but not in the interface. However I do not know how to map this in Windows or whenever something links to features you need a newer standard C++/template library because then people still need to upgrade. So the safe way would be to make the library stuff compatible from whatever minimum C++ standard version is desired (11/14/17) but pushing all users to C++20 might make exiv2 unsuitable for many of those who use it today.

@neheb
Copy link
Collaborator Author

neheb commented Jul 1, 2023

Right. The headers are still kept at C++11. On that note, if constexpr should be removed from them as compilers are not free to add it implicitly as I originally thought, making the templates much less efficient.

As far as Windows is concerned, that's not an issue. In the case of MSVC, the libraries are upgrade-able, I actually don't know if older MSVC can even compile exiv2. I remember MSVC2019 or something just crashing when trying to compile exiv2. No errors printed.

On that note, there's currently an issue where Exiv2 is incompatible with msvcrt. Given that it's deprecated by Microsoft, I see no value in supporting it. See #2637

@neheb neheb force-pushed the h branch 5 times, most recently from 9c58408 to 676aac1 Compare July 12, 2023 17:20
@kmilos
Copy link
Collaborator

kmilos commented Jul 13, 2023

Btw, might be an idea to hold off on this for a couple of 0.28.x bugfix releases, just so it remains easy to backport stuff from the main branch?

@neheb
Copy link
Collaborator Author

neheb commented Jul 13, 2023

This is still draft after all.

@neheb neheb force-pushed the h branch 4 times, most recently from 21cbd59 to 959b4df Compare July 19, 2023 02:03
@neheb
Copy link
Collaborator Author

neheb commented Jul 19, 2023

Yeah I'm not sure of this PR anymore. People are still using GCC7 to compile Exiv2. std::endian comes with GCC8 and starts_with GCC9. Let's not mention other projects that are on C++14 to allow building with CentOS7. This is going to be a draft for a while....

src/easyaccess.cpp Dismissed
template <size_t N, const char* const (&keys)[N]>
ExifData::const_iterator findMetadatum(const ExifData& ed) {
for (const auto& k : keys) {
auto pos = ed.findKey(ExifKey(k));

Check warning

Code scanning / CodeQL

NULL iterator deref Warning

Iterator returned by findKey might cause a null deref
here
.
Iterator returned by findKey might cause a null deref
here
.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wrong.

if (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD 20)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd still leave this gated (but bumped to 20 obviously) - it was pretty useful to be able to override from the command line for e.g. future messing w/ C++23 and C++26...

neheb added 14 commits January 23, 2025 17:23
This breaks support for older compilers, especially ones that don't have
any support for C++20.

Signed-off-by: Rosen Penev <[email protected]>
GCC and Clang greater than 8 don't need this. Remove it.

Signed-off-by: Rosen Penev <[email protected]>
Now that older platforms are going away, we can migrate.

Also get rid of std::filesystem handling. Not needed with newer
compilers.

Signed-off-by: Rosen Penev <[email protected]>
Signed-off-by: Rosen Penev <[email protected]>
Signed-off-by: Rosen Penev <[email protected]>
It's a standard C++20 header.

Signed-off-by: Rosen Penev <[email protected]>
Found with readability-container-contains

Signed-off-by: Rosen Penev <[email protected]>
Found with modernize-use-nodiscard

Signed-off-by: Rosen Penev <[email protected]>
Found with misc-use-internal-linkage

Signed-off-by: Rosen Penev <[email protected]>
Supported since GCC8.

Signed-off-by: Rosen Penev <[email protected]>
Signed-off-by: Rosen Penev <[email protected]>
Signed-off-by: Rosen Penev <[email protected]>
Cast isspace to unsigned char for proper C API.

Signed-off-by: Rosen Penev <[email protected]>
@neheb neheb merged commit 95caaa2 into Exiv2:main Jan 24, 2025
59 checks passed
@neheb neheb deleted the h branch January 24, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants