C++ error detected
-
I have installed qt creator on ubuntu 20.04 using those commands line :
sudo apt install qtcreator sudo apt install qt5-default sudo apt install build-essential
Every time i use c++ it make errors like for example when i create a plain c++ application from the beginning of this main code
#include <iostream> int main() { std::cout << "Hello World!" << std::endl; return 0; }
it give those error :
/work/QT project/PlainCppApp/main.cpp:2: error: expected a type /work/QT project/PlainCppApp/main.cpp:2: error: expected unqualified-id /work/QT project/PlainCppApp/main.cpp:2: error: expected '}' /usr/include/c++/9/ostream:42: to match this '{' /work/QT project/PlainCppApp/main.cpp:5: error: no member named 'cout' in namespace 'std'
I want to use c++ 17 because i have some library from this version i have to use, and i want gcc compiler but it always use clang
Thank you in advance. -
Hi,
Since you want to use the C++17 standard, did you request it ?
Are you using qmake or cmake ? -
@Ran_Flora
qmake:CONFIG += c++1z
camke: Not sure, seems to vary by compiler, e.g. for gcc see https://stackoverflow.com/a/77408925/489865 ? -
What puzzles me is the error in line 2 - are you sure your system headers are correct and not screwed up somehow? This looks not like a problem with your code you are showing.
-
-
@Ran_Flora
As @Christian-Ehrlicher has said, the error message about "missing}
for{
" immediately after#include <iostream>
makes it seem like that file (or something it includes) is somehow incorrect.....