How to install C17 on Linux and setup QT Creator?
-
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 ? -
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. -
@Natural_Bugger
Did you try applying the principles shown in that last link to your Qt 5.9.9 situation? -
@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.... -
https://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.
-
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)
-
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); | ``` ^
-
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.) -
thank 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 ...