Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator: no member named 'ranges' in namespace 'std'
Forum Update on Monday, May 27th 2025

Qt Creator: no member named 'ranges' in namespace 'std'

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 4 Posters 6.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    slawtul
    wrote on 13 Jul 2020, 07:51 last edited by
    #1

    Hi guys

    I have 'visual' problem in Qt Creator. Qt Creator marks std::ranges with above error message however I can build and run program. I use gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) (GCC)
    Do you know how to fix it?

    Regards
    Slawek

    2833ce56-c7bc-47ac-b016-998f66da9ed6-image.png

    J 1 Reply Last reply 13 Jul 2020, 08:08
    0
    • S slawtul
      13 Jul 2020, 07:51

      Hi guys

      I have 'visual' problem in Qt Creator. Qt Creator marks std::ranges with above error message however I can build and run program. I use gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) (GCC)
      Do you know how to fix it?

      Regards
      Slawek

      2833ce56-c7bc-47ac-b016-998f66da9ed6-image.png

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 13 Jul 2020, 08:08 last edited by
      #2

      @slawtul Did you include <ranges>?

      Please post your code as text not screen shots.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 13 Jul 2020, 09:27
      0
      • J jsulm
        13 Jul 2020, 08:08

        @slawtul Did you include <ranges>?

        Please post your code as text not screen shots.

        S Offline
        S Offline
        slawtul
        wrote on 13 Jul 2020, 09:27 last edited by
        #3

        @jsulm

        Hi,
        yes, I have <ranges> in Playground.h file - I forgot to move it to Playground.cpp but even when I move it to cpp file there is still error message.
        I opened this project under Clion IDE and it's ok.

        #ifndef PLAYGROUND_H
        #define PLAYGROUND_H
        
        #include <iostream>
        #include <ranges>
        
        class Playground {
        public:
          void showABCWithRange();
        };
        
        #endif // PLAYGROUND_H
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          slawtul
          wrote on 13 Jul 2020, 09:30 last edited by
          #4

          Proof:

          #include <iostream>
          #include <ranges>
          
          #include "Playground.h"
          
          void Playground::showABCWithRange() {
            std::cout << std::ranges::size("ABC") << "\n";
          }
          
          Process Error: 5
          Output:
          /home/slawtul/sources/Cpp_tools/Playground_lib/Playground.cpp:7:21: error: no member named 'ranges' in namespace 'std'
            std::cout << std::ranges::size("ABC") << "\n";
                         ~~~~~^
          1 error generated.
          11:28:42: Error: Failed to analyze 1 files.
          
          J 1 Reply Last reply 13 Jul 2020, 09:46
          0
          • S slawtul
            13 Jul 2020, 09:30

            Proof:

            #include <iostream>
            #include <ranges>
            
            #include "Playground.h"
            
            void Playground::showABCWithRange() {
              std::cout << std::ranges::size("ABC") << "\n";
            }
            
            Process Error: 5
            Output:
            /home/slawtul/sources/Cpp_tools/Playground_lib/Playground.cpp:7:21: error: no member named 'ranges' in namespace 'std'
              std::cout << std::ranges::size("ABC") << "\n";
                           ~~~~~^
            1 error generated.
            11:28:42: Error: Failed to analyze 1 files.
            
            J Offline
            J Offline
            J.Hilk
            Moderators
            wrote on 13 Jul 2020, 09:46 last edited by
            #5

            @slawtul ranges requires c++20 did you enable that ? And does your compiler support it?


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            J 1 Reply Last reply 13 Jul 2020, 10:14
            1
            • J J.Hilk
              13 Jul 2020, 09:46

              @slawtul ranges requires c++20 did you enable that ? And does your compiler support it?

              J Offline
              J Offline
              JonB
              wrote on 13 Jul 2020, 10:14 last edited by
              #6

              @J-Hilk
              I'm sure that is indeed the issue, though it's slightly surprising that OP is successfully using #include <ranges> without that complaining.... Must be that the file does exist but does nothing inside it if C++ < 20 ?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                slawtul
                wrote on 13 Jul 2020, 10:25 last edited by slawtul
                #7

                Hi
                I mentioned in the first post that program builds and runs - both from terminal and from Qt Creator.

                Below few lines from CMakeList.txt:

                cmake_minimum_required(VERSION 3.15)
                project(Cpp_tools)
                
                set(CMAKE_CXX_STANDARD 20)
                add_compile_options(-Wall -Wextra -Wpedantic -Werror)
                

                Do I need to enable 'something else' in Qt Creator to get ride of this error message?

                From my konsole:

                [slawtul@localhost ~]$ gcc -v
                gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) (GCC) 
                
                [slawtul@localhost ~]$ clang -v
                clang version 10.0.0 (Fedora 10.0.0-2.fc32)
                

                Thanks!
                Slawek

                J 1 Reply Last reply 13 Jul 2020, 10:28
                0
                • S slawtul
                  13 Jul 2020, 10:25

                  Hi
                  I mentioned in the first post that program builds and runs - both from terminal and from Qt Creator.

                  Below few lines from CMakeList.txt:

                  cmake_minimum_required(VERSION 3.15)
                  project(Cpp_tools)
                  
                  set(CMAKE_CXX_STANDARD 20)
                  add_compile_options(-Wall -Wextra -Wpedantic -Werror)
                  

                  Do I need to enable 'something else' in Qt Creator to get ride of this error message?

                  From my konsole:

                  [slawtul@localhost ~]$ gcc -v
                  gcc version 10.1.1 20200507 (Red Hat 10.1.1-1) (GCC) 
                  
                  [slawtul@localhost ~]$ clang -v
                  clang version 10.0.0 (Fedora 10.0.0-2.fc32)
                  

                  Thanks!
                  Slawek

                  J Offline
                  J Offline
                  J.Hilk
                  Moderators
                  wrote on 13 Jul 2020, 10:28 last edited by
                  #8

                  @slawtul well, than its a clang code model issue,
                  not all too surprising, IIRC c++20 support for clang code model is not jet finished


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  1
                  • S Offline
                    S Offline
                    slawtul
                    wrote on 13 Jul 2020, 10:47 last edited by
                    #9

                    @J-Hilk

                    Ok, now I understand and found Clang Code Model you are reffering to...
                    So 'under the hood' Qt Creator checks my code with Clang 10.0.0 version which does not have <ranges> implemented.

                    Thanks!

                    6c17f11c-2ad2-43ab-92a3-999d3895b619-image.png

                    1 Reply Last reply
                    2

                    1/9

                    13 Jul 2020, 07:51

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved