Skip to content

error: #error C++ versions less than C++17 are not supported. #393

Closed

Description

@vt-alt

When building latest release v0.10.0, there is build error:

23:02:14 [ 73%] Built target list_cpu_features
23:02:14 gmake[1]: Leaving directory '/usr/src/RPM/BUILD/cpu_features-0.10.0/x86_64-alt-linux'
23:02:14 gmake[2]: Entering directory '/usr/src/RPM/BUILD/cpu_features-0.10.0/x86_64-alt-linux'
23:02:14 [ 55%] Building CXX object test/CMakeFiles/string_view_test.dir/string_view_test.cc.o
23:02:14 cd /usr/src/RPM/BUILD/cpu_features-0.10.0/x86_64-alt-linux/test && /usr/bin/c++ -DCPU_FEATURES_TEST -I/usr/src/RPM/BUILD/cpu_features-0.10.0/test/../include -pipe -frecord-gcc-switches -Wall -fdiagnostics-color=always -g -O2 -flto=auto -O2 -DNDEBUG -std=c++14 -fPIE -MD -MT test/CMakeFiles/string_view_test.dir/string_view_test.cc.o -MF CMakeFiles/string_view_test.dir/string_view_test.cc.o.d -o CMakeFiles/string_view_test.dir/string_view_test.cc.o -c /usr/src/RPM/BUILD/cpu_features-0.10.0/test/string_view_test.cc
23:02:14 In file included from /usr/include/gtest/gtest-message.h:57,
23:02:14                  from /usr/include/gtest/gtest-assertion-result.h:46,
23:02:14                  from /usr/include/gtest/gtest.h:63,
23:02:14                  from /usr/src/RPM/BUILD/cpu_features-0.10.0/test/string_view_test.cc:17:
23:02:14 /usr/include/gtest/internal/gtest-port.h:273:2: error: #error C++ versions less than C++17 are not supported.
23:02:14   273 | #error C++ versions less than C++17 are not supported.
23:02:14       |  ^~~~~
23:02:14 In file included from /usr/include/gtest/gtest.h:67:
23:02:14 /usr/include/gtest/gtest-param-test.h:483:56: error: missing template arguments before '(' token
23:02:14   483 |           typename StdFunction = decltype(std::function(std::declval<Func>()))>
23:02:14       |                                                        ^
23:02:14 /usr/include/gtest/gtest-param-test.h:493:56: error: missing template arguments before '(' token
23:02:14   493 |           typename StdFunction = decltype(std::function(std::declval<Func>()))>
23:02:14       |                                                        ^
23:02:14 gmake[2]: *** [test/CMakeFiles/string_view_test.dir/build.make:79: test/CMakeFiles/string_view_test.dir/string_view_test.cc.o] Error 1

Perhaps this is related to -std=c++14 which you set in CMakeLists.txt if BUILD_TESTING is defined.

Activity

  1. Mizux commented on May 5, 2025

    @Mizux
    Collaborator

    FYI Google OSS C++ Policy drop support of C++14 in December 17th 2024, the now minimum supported is C++17 -> maybe Cpu Feature should align too (i.e. drop C++14 support in favor of C++17 as minimum)
    ref: https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md

  2. added
    wontfix
    compilation error
    on May 5, 2025
  3. added theissue type on May 5, 2025
  4. gchatelet commented on May 5, 2025

    @gchatelet
    Collaborator

    Yes, I think there is not much we can do about this on our side. This is entirely linked to GTest. I think the proper way to handle this is for you to disable tests if your compiler does not support C++17 :-/ I understand this is not great though.

    Marking this issue as closed as its out of our direct control.

  5. vt-alt commented on May 5, 2025

    @vt-alt
    Author

    But, removing the offending lines from your CMakeLists.txt still lets the tests to compile and successfully run.

    23:22:37 + sed -i /CMAKE_CXX_STANDARD/d CMakeLists.txt
    ...
    + ctest --test-dir x86_64-alt-linux
    Test project /usr/src/RPM/BUILD/cpu_features-0.10.0/x86_64-alt-linux
        Start 1: bit_utils_test
        Start 2: string_view_test
        Start 3: stack_line_reader_test
        Start 4: cpuinfo_x86_test
    1/4 Test #1: bit_utils_test ...................   Passed    0.00 sec
    2/4 Test #2: string_view_test .................   Passed    0.00 sec
    3/4 Test #3: stack_line_reader_test ...........   Passed    0.00 sec
    4/4 Test #4: cpuinfo_x86_test .................   Passed    0.00 sec
    
    100% tests passed, 0 tests failed out of 4
    
  6. vt-alt commented on May 5, 2025

    @vt-alt
    Author

    Our compiler supports C++17 since it's recent gcc 14.2.1. Your code downgrades compiler capabilities intentionally with -std=c++14 compile option. You achieve this with these lines in your CMakeLists.txt:

    if(BUILD_TESTING)
    ...
    set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
  7. Mizux commented on May 6, 2025

    @Mizux
    Collaborator

    2 problems here:

    1. C++14 Support is broken: deprecated and can't be supported anymore -> i.e. we drop the support.
    2. Current CMakeLists.txt force standard to C++14 when building tests: Here I would default to C++17 instead unless CMAKE_CXX_STANDARD is already defined (e.g. C++20 in a super build project)...
      ref:

      cpu_features/CMakeLists.txt

      Lines 209 to 216 in 14b80e8

      if(BUILD_TESTING)
      # Automatically incorporate googletest into the CMake Project if target not
      # found.
      enable_language(CXX)
      set(CMAKE_CXX_STANDARD 14)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14
  8. gchatelet commented on May 6, 2025

    @gchatelet
    Collaborator

    Oops my bad I misread your original post and my answer was not relevant. My apologies for this.
    After discussing with @Mizux we've decided to force the standard to C++17 (if not already set).
    Working on a patch right now.

  9. modified the milestone: v0.10.0 on May 6, 2025
  10. gchatelet commented on May 6, 2025

    @gchatelet
    Collaborator

    @vt-alt can I ask you to check the fix?
    If so, I'll add a known issue on the v0.10.0 release page and create a v0.10.1.

  11. gchatelet commented on May 6, 2025

    @gchatelet
    Collaborator

    @vt-alt can I ask you to check the fix? If so, I'll add a known issue on the v0.10.0 release page and create a v0.10.1.

    Scratch that, the patch broke the CI, I'll revert it and do a proper PR.

  12. removed
    wontfix
    on May 6, 2025
  13. added this to the v0.10.1 milestone on May 6, 2025
  14. added 2 commits that reference this issue on May 10, 2025
    07a7331
    2e2574e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilation error

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions