From ab28cdbd1bc04d72139c5b7e3236bbdf8c19b585 Mon Sep 17 00:00:00 2001 From: Paul Dreik Date: Sun, 12 Jan 2025 14:47:16 +0100 Subject: [PATCH] switch to C++17 --- .github/workflows/debian-bookworm.yml | 4 ++-- .github/workflows/debian-bullseye.yml | 4 ++-- .github/workflows/debian-trixie.yml | 4 ++-- .github/workflows/fedora-40.yml | 4 ++-- .github/workflows/fedora-41.yml | 4 ++-- .github/workflows/mac.yml | 2 +- .github/workflows/ubuntu-default.yml | 4 ++-- NEWS | 2 ++ README.md | 2 +- configure.ac | 8 ++++---- cppcheck/run_cppcheck.sh | 2 +- do_quality_checks.sh | 20 ++++++++++---------- 12 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/debian-bookworm.yml b/.github/workflows/debian-bookworm.yml index fb95bb4..99913be 100644 --- a/.github/workflows/debian-bookworm.yml +++ b/.github/workflows/debian-bookworm.yml @@ -21,13 +21,13 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 - name: build with hardened build flags run: | make clean diff --git a/.github/workflows/debian-bullseye.yml b/.github/workflows/debian-bullseye.yml index 5860fde..f27cacb 100644 --- a/.github/workflows/debian-bullseye.yml +++ b/.github/workflows/debian-bullseye.yml @@ -21,13 +21,13 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 - name: build with hardened build flags run: | make clean diff --git a/.github/workflows/debian-trixie.yml b/.github/workflows/debian-trixie.yml index d56e9f7..80460d9 100644 --- a/.github/workflows/debian-trixie.yml +++ b/.github/workflows/debian-trixie.yml @@ -21,13 +21,13 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 - name: build with hardened build flags run: | make clean diff --git a/.github/workflows/fedora-40.yml b/.github/workflows/fedora-40.yml index 2570d08..ebc004d 100644 --- a/.github/workflows/fedora-40.yml +++ b/.github/workflows/fedora-40.yml @@ -21,13 +21,13 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make -j $(nproc) - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 - name: store the logs as an artifact if: ${{ always() }} uses: actions/upload-artifact@v4 diff --git a/.github/workflows/fedora-41.yml b/.github/workflows/fedora-41.yml index 2da0ff2..572ad5c 100644 --- a/.github/workflows/fedora-41.yml +++ b/.github/workflows/fedora-41.yml @@ -21,13 +21,13 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make -j $(nproc) - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 - name: store the logs as an artifact if: ${{ always() }} uses: actions/upload-artifact@v4 diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 6f487db..0e07f73 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -23,7 +23,7 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS="-std=c++11 -I$(brew --prefix nettle)/include -L$(brew --prefix nettle)/lib" + run: ./configure --enable-warnings CXXFLAGS="-std=c++17 -I$(brew --prefix nettle)/include -L$(brew --prefix nettle)/lib" - name: make run: make # tests fail because readlink does not understand -f on mac diff --git a/.github/workflows/ubuntu-default.yml b/.github/workflows/ubuntu-default.yml index e3ccd14..6902b4a 100644 --- a/.github/workflows/ubuntu-default.yml +++ b/.github/workflows/ubuntu-default.yml @@ -23,10 +23,10 @@ jobs: - name: bootstrap run: ./bootstrap.sh - name: configure - run: ./configure --enable-warnings CXXFLAGS=-std=c++11 + run: ./configure --enable-warnings CXXFLAGS=-std=c++17 - name: make run: make - name: make check run: make check - name: make distcheck - run: make distcheck CXXFLAGS=-std=c++11 + run: make distcheck CXXFLAGS=-std=c++17 diff --git a/NEWS b/NEWS index d72bf82..c33dd4d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +next +requires a C++17 capable compiler. 1.6.0 supports sha512 1.4.0alpha diff --git a/README.md b/README.md index 49e3bc6..d05a9ee 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you are on Mac, you can install through - [MacPorts](https://www.macports.org/) (direct link to [Portfile](https://github.com/macports/macports-ports/blob/master/sysutils/rdfind/Portfile)). - [brew](https://brew.sh/) direct link to [homebrew formulae](https://formulae.brew.sh/formula/rdfind) -If you want to compile the source yourself, that is fine. Rdfind is written in C++11 and should compile under any \*nix. +If you want to compile the source yourself, that is fine. Rdfind is written in C++17 and should compile under any \*nix. ### Windows diff --git a/configure.ac b/configure.ac index a9068fc..58a37fc 100644 --- a/configure.ac +++ b/configure.ac @@ -60,11 +60,11 @@ AC_CHECK_FUNC(stat,,AC_MSG_ERROR(oops! no stat ?!?)) dnl check for 64 bit support AC_SYS_LARGEFILE -dnl make sure we have c++11 or better, -AC_MSG_CHECKING([for C++11 support or better]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int f() { auto a=1;return a;}])], +dnl make sure we have c++17 or better, +AC_MSG_CHECKING([for C++17 support or better]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int f() { if constexpr(true) {auto a=1;return a;} else {return 2;}}])], [AC_MSG_RESULT([yes])], - [AC_MSG_ERROR([no c++11 support, please set CXXFLAGS properly])]) + [AC_MSG_ERROR([no c++17 support, please set CXXFLAGS properly])]) AC_SUBST(VERSION) diff --git a/cppcheck/run_cppcheck.sh b/cppcheck/run_cppcheck.sh index b1f93e3..523c01b 100755 --- a/cppcheck/run_cppcheck.sh +++ b/cppcheck/run_cppcheck.sh @@ -7,7 +7,7 @@ me=$(basename $0) mkdir -p $outdir -args="--enable=all --inconclusive --std=c++11 -I . --quiet --suppress=missingIncludeSystem" +args="--enable=all --inconclusive --std=c++17 -I . --quiet --suppress=missingIncludeSystem" # cppcheck can not produce an xml report and a reulgar text file at the same time, so run twice cppcheck $args *.cc *.hh --template='{severity}:{file}:{line}:{message}' 2>$outdir/cppcheck.out diff --git a/do_quality_checks.sh b/do_quality_checks.sh index da0a71d..504a0fb 100755 --- a/do_quality_checks.sh +++ b/do_quality_checks.sh @@ -100,15 +100,15 @@ compile_and_test() { #this is the test program to compile, so we know the compiler and standard lib #works. clang 4 with c++2a does not. /bin/echo -e "#include ">x.cpp - #does the compiler understand c++11? That is mandatory. - if ! $1 -c x.cpp -std=c++11 >/dev/null 2>&1 ; then - echo $me: this compiler $1 does not understand c++11 + #does the compiler understand c++17? That is mandatory. + if ! $1 -c x.cpp -std=c++17 >/dev/null 2>&1 ; then + echo $me: this compiler $1 does not understand c++17 return 0 fi - #loop over all standard flags>=11 and try those which work. + #loop over all standard flags>=17 and try those which work. #use the code words. - for std in 11 1y 1z 2a 2b ; do + for std in 1z 2a 2b ; do if ! $1 -c x.cpp -std=c++$std >/dev/null 2>&1 ; then echo $me: compiler does not understand c++$std, skipping this combination. else @@ -197,11 +197,11 @@ run_with_libcpp() { int main() { std::cout<<\"libc++ works!\"<x.cpp get_latest_clang if [ ! -z $latestclang ] ; then - if ! $latestclang -std=c++11 -stdlib=libc++ -lc++abi x.cpp >/dev/null 2>&1 || [ ! -x ./a.out ] || ! ./a.out ; then + if ! $latestclang -std=c++17 -stdlib=libc++ -lc++abi x.cpp >/dev/null 2>&1 || [ ! -x ./a.out ] || ! ./a.out ; then echo $me: "debug: $latestclang could not compile with libc++ - perhaps uninstalled." continue fi - compile_and_test_standard $latestclang c++11 "-stdlib=libc++ -D_LIBCPP_DEBUG=1" + compile_and_test_standard $latestclang c++17 "-stdlib=libc++ -D_LIBCPP_DEBUG=1" return fi # we will get here if no clang could be found. that is not an error, @@ -247,7 +247,7 @@ verify_self_contained_headers() { fi for header in *.hh ; do cp $header tmp.cc - if ! g++ -std=c++11 -I. -c tmp.cc -o /dev/null >header.log 2>&1 ; then + if ! g++ -std=c++17 -I. -c tmp.cc -o /dev/null >header.log 2>&1 ; then echo "$me: found a header which is not self contained: $header." echo "$me: see header.log for details" exit 1 @@ -349,7 +349,7 @@ run_with_debian_buildflags #make a test build with debug iterators ASSERT="--enable-assert" -compile_and_test_standard g++ c++11 "-D_GLIBCXX_DEBUG" +compile_and_test_standard g++ c++17 "-D_GLIBCXX_DEBUG" #test run with clang/libc++ ASSERT="--enable-assert" @@ -361,7 +361,7 @@ run_with_libcpp if which valgrind >/dev/null; then echo $me: running unit tests through valgrind ASSERT="--disable-assert" - compile_and_test_standard g++ c++11 "-O3" + compile_and_test_standard g++ c++17 "-O3" VALGRIND=valgrind make check >make-check.log fi