Qt Creator: no member named 'ranges' in namespace 'std'
-
wrote on 13 Jul 2020, 07:51 last edited by
-
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@slawtul Did you include <ranges>?
Please post your code as text not screen shots.
-
wrote on 13 Jul 2020, 09:27 last edited by
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
-
wrote on 13 Jul 2020, 09:30 last edited by
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.
-
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.
@slawtul ranges requires c++20 did you enable that ? And does your compiler support it?
-
wrote on 13 Jul 2020, 10:14 last edited by
@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 ? -
wrote on 13 Jul 2020, 10:25 last edited by slawtul
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 -
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@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 -
wrote on 13 Jul 2020, 10:47 last edited by
1/9