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

Use of C++17/20 features/extensions #432

Open
ThisIsFineTM opened this issue Oct 14, 2024 · 6 comments
Open

Use of C++17/20 features/extensions #432

ThisIsFineTM opened this issue Oct 14, 2024 · 6 comments
Assignees
Labels
Milestone

Comments

@ThisIsFineTM
Copy link

The src/zimwriterfs/zimcreatorfs.cpp file uses designated initializers, which is a c++20 feature. It currently works by relying on compiler c++20-extensions with the c++ standard set to c++17 in meson.build.

Are there any dependency blockers for just changing the c++ standard version to c++20? If there aren't any blockers I can put in a PR.

@kelson42
Copy link
Contributor

We want to keep things compiling on older compilers. The strategy is to allow c++ 14 features but not higher.

@kelson42 kelson42 added this to the 3.6.0 milestone Oct 15, 2024
@kelson42 kelson42 self-assigned this Oct 15, 2024
@ThisIsFineTM
Copy link
Author

It would be helpful if we could figure out which minimum compiler version we specifically want to target. The codebase already uses some >= C++17 features, so those sections would need a downgrade to comply with the intended target of C++14. Is the Repology page accurate?

@kelson42
Copy link
Contributor

kelson42 commented Oct 15, 2024

We have to compile on cpp14 compilers, therefore we should not use moderner breaking forms.

Do you have some kind of detailed report showing that the code is not cpp14 compliant anymore?

@ThisIsFineTM
Copy link
Author

Hi Kelson,

Thank you for the quick reply. Here are the ones that stood out to me.

default_options : ['c_std=c11', 'cpp_std=c++17', 'werror=true', 'warning_level=1'])

4: default_options : ['c_std=c11', 'cpp_std=c++17', 'werror=true', 'warning_level=1'])
                                   ^^^^^^^^^^^^^^^^

Redirect redirect = {

45:    Redirect redirect = {
         .path= matches[1].str(),    // designated initializers are a c++20 feature 
         .title = matches[2].str(),  // and only work prior to that using a compiler extension
         .target = matches[3].str()  // If you change warning_level=3 in meson.build
       };                            // it will show -Werror=c++20-extensions

I also found this https://github.com/openzim/zim-tools/wiki/Repology, but I am not sure if that is up to date. I am just trying to figure out which specific compiler versions are the bare minimum we want to support so it can be documented (and so I can install those versions in a container so I can test locally). Just picking out of that repology list and a cursory internet search:

Debian 10 uses GCC 10
Alpine Linux 3.16 uses LLVM 13
Ubuntu 22.04 uses GCC 11.2
Raspbian Oldstable uses GCC 8

@ThisIsFineTM
Copy link
Author

ThisIsFineTM commented Dec 5, 2024

As a bit of a followup:

libzim targets c++17.
https://github.com/openzim/libzim/blob/40bfe6470490fb52b0a44a9fdab8ddbaad37b181/meson.build#L4

xapian-core targets c++11
https://github.com/openzim/xapian-meson/blob/d3efba172e832ce9b0860996576e96eef7850d83/xapian-core/meson.build#L2

kiwix-tools targets c++17
https://github.com/kiwix/kiwix-tools/blob/e65354a486376445d809f4a1dd7e3394b5e933ba/meson.build#L4

libkiwix targets c++17
https://github.com/kiwix/libkiwix/blob/6c37e2827e6ccf0497d20b5cfe1696df6481c4ed/meson.build#L4

The oldest compiler I found in the Repology link https://github.com/openzim/zim-tools/wiki/Repology was GCC 8 with Raspbian Oldstable.

Checking the support pages, the c++17 support for GCC 8 is complete, and a majority of the c++17 standard library features are supported as well. The only standard library features which are not supported were pmr, parallel algorithms, and hardware_inference_size, which are generally of more niche use cases anyway. Most of c++17 is supported back in GCC 7.
https://en.cppreference.com/w/cpp/compiler_support/17
https://en.cppreference.com/w/cpp/compiler_support/17#C.2B.2B17_library_features

@ThisIsFineTM ThisIsFineTM changed the title Use of C++20 features/extensions Use of C++17/20 features/extensions Dec 5, 2024
@ThisIsFineTM
Copy link
Author

It looks like C++17 target was added in this repository August 30, 2023 by @mgautierfr:

297e672

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

No branches or pull requests

2 participants