How to install C17 on Linux and setup QT Creator?
-
wrote on 15 Aug 2020, 18:12 last edited by Natural_Bugger
https://gcc.godbolt.org/z/WXKLCk
#include <iostream> #include <iterator> int arr[3][3]; auto it=begin(arr); cout<<"Hello"<<*(*it+1)<<endl;
errors;
error: no matching function for call to ‘begin(char [n][n])’ 63 | auto it=begin(grid); | ^ error: no matching function for call to 'begin'
typing "std::" ... begin() ... doesn't show up in the context menu.
i have the same headers files, what am i doing wrong? -
https://gcc.godbolt.org/z/WXKLCk
#include <iostream> #include <iterator> int arr[3][3]; auto it=begin(arr); cout<<"Hello"<<*(*it+1)<<endl;
errors;
error: no matching function for call to ‘begin(char [n][n])’ 63 | auto it=begin(grid); | ^ error: no matching function for call to 'begin'
typing "std::" ... begin() ... doesn't show up in the context menu.
i have the same headers files, what am i doing wrong?@Natural_Bugger
IIRC std::begin requieres at least c++11 ? (Or 17)
To what did. you set the Compiler ? -
@Natural_Bugger
IIRC std::begin requieres at least c++11 ? (Or 17)
To what did. you set the Compiler ?wrote on 16 Aug 2020, 06:55 last edited by Natural_Bugger@J-Hilk
hi, i have QT version 5.9.9 GCC, as it came out of the box.
compiler C++ GCC (C++, x86, 64bit in /usr/bin)i downloaded c17
https://askubuntu.com/questions/1113974/using-c17-with-clang-on-ubuntu-16-04all good and resided in "/usr/include/c++/9"
what to do next?i found some info:
https://amirkoblog.wordpress.com/2018/08/14/creating-c17-enabled-qt-projects/
but ... that applies to Qt 5.11. -
@J-Hilk
hi, i have QT version 5.9.9 GCC, as it came out of the box.
compiler C++ GCC (C++, x86, 64bit in /usr/bin)i downloaded c17
https://askubuntu.com/questions/1113974/using-c17-with-clang-on-ubuntu-16-04all good and resided in "/usr/include/c++/9"
what to do next?i found some info:
https://amirkoblog.wordpress.com/2018/08/14/creating-c17-enabled-qt-projects/
but ... that applies to Qt 5.11.wrote on 16 Aug 2020, 07:05 last edited by@Natural_Bugger
Did you try applying the principles shown in that last link to your Qt 5.9.9 situation? -
@Natural_Bugger
Did you try applying the principles shown in that last link to your Qt 5.9.9 situation?wrote on 16 Aug 2020, 07:12 last edited bythat's what I'm trying to figuring out.
that article applies to windows.i'm not sure what to do now
-
@Natural_Bugger
Did you try applying the principles shown in that last link to your Qt 5.9.9 situation?wrote on 16 Aug 2020, 07:19 last edited byadd new kit?
but how to point to "/usr/include/c++/9"? -
add new kit?
but how to point to "/usr/include/c++/9"?wrote on 16 Aug 2020, 07:23 last edited by@Natural_Bugger
Sorry, I only know to follow the principle there, I can't tell you exactly what to do. For me I just accept it as-is initially under Ubuntu and it works fine, so someone else will have to help.... -
add new kit?
but how to point to "/usr/include/c++/9"?wrote on 16 Aug 2020, 07:30 last edited byhttps://askubuntu.com/questions/859256/how-to-install-gcc-7-or-clang-4-0
sudo apt-get install gcc-8 g++-8all fine and will install, but not to figure out where it is.
-
@Natural_Bugger
Sorry, I only know to follow the principle there, I can't tell you exactly what to do. For me I just accept it as-is initially under Ubuntu and it works fine, so someone else will have to help....wrote on 16 Aug 2020, 08:24 last edited bythnx, very much sofar.
-
that's what I'm trying to figuring out.
that article applies to windows.i'm not sure what to do now
You don't have to download a specific and new compiler, any you have installed should be c++14/17 capable.
You just have to tell it that you want to use a specific or the latest standard
hat's what I'm trying to figuring out.
that article applies to windows.i'm not sure what to do now
doesn't matter if windows or not, the pricinple is the same.
To enable a specific c++ support you have to add to your pro file
CONFIG += C++17
for c++17 support, if you're using qt15 than c++latest is also an optionI'f you're using cmake as your build system, than this should set the compiler to c++17
set(CMAKE_CXX_STANDARD 17)
-
You don't have to download a specific and new compiler, any you have installed should be c++14/17 capable.
You just have to tell it that you want to use a specific or the latest standard
hat's what I'm trying to figuring out.
that article applies to windows.i'm not sure what to do now
doesn't matter if windows or not, the pricinple is the same.
To enable a specific c++ support you have to add to your pro file
CONFIG += C++17
for c++17 support, if you're using qt15 than c++latest is also an optionI'f you're using cmake as your build system, than this should set the compiler to c++17
set(CMAKE_CXX_STANDARD 17)
wrote on 16 Aug 2020, 09:08 last edited by Natural_Bugger@J-Hilk
hi and thnx,
i added " CONFIG += C++14 " to the project file.
C14 is enough to pass the test.
but i still get the same error.int n = 9; char grid[n][n]; auto it=std::begin(grid); cout<<"Hello"<<*(*it+1)<<endl;
errors.
error: no matching function for call to 'begin' error: no matching function for call to ‘begin(char [n][n])’ 63 | auto it=std::begin(grid); | ^
using lower case c, i have one less error.
" CONFIG += c++14 "error: no matching function for call to ‘begin(char [n][n])’ 63 | auto it=std::begin(grid); | ``` ^
-
wrote on 16 Aug 2020, 09:17 last edited by JonB
I don't think you should be needing different compilers from what Ubuntu ships with.
I am not a C++ expert, but I'm not at all sure
int n = 9; char grid[n][n]; auto it=std::begin(grid);
is OK. For example, I think changing to
constexpr int n = 9;
will make it compile at thestd::begin()
. What evidence do you have that what you have written is supported? (Well that change makes it work with C++14, you may know more than I about which compiler version is wanted/required.) -
I don't think you should be needing different compilers from what Ubuntu ships with.
I am not a C++ expert, but I'm not at all sure
int n = 9; char grid[n][n]; auto it=std::begin(grid);
is OK. For example, I think changing to
constexpr int n = 9;
will make it compile at thestd::begin()
. What evidence do you have that what you have written is supported? (Well that change makes it work with C++14, you may know more than I about which compiler version is wanted/required.)wrote on 16 Aug 2020, 09:25 last edited bythank you very much and it did compile, even when return to c11.
: )well, i want that piece of code to go over rows and columns in an elegant fashion, not using nested for loops.
i found that piece of code on stack exchange, than i found out it didn't compile on my system, but it did on online cpp compilers like: https://gcc.godbolt.org/ and you couldn't solve that ...
1/13