lundi 25 février 2019

How to use C++11 in Qt creator 4.8

I have looked everywhere and the solution to this is to add a line of code to a '.pro' file in my project. I cannot see any such files though! I can see a qbs file, the main.cpp file and a xcode.qbs file.

This is how I started: using a Mac, I installed Qt Creator 4.8 (Clang v5.12) and I created a 'plain C++ project' which uses Qmake.

I am using the {} to initialise a variable but it won't allow me to. I had a similar problem with Eclipse and found a solution. Any help, please?

This is the code I am testing:

#include <iostream>

int main()
 {
   int a{5};
   std::cout << a;
   return 0;
  }

The error code for the line where I define a is: "/Users/xxxxxx/Coding/HelloEarth/main.cpp:5: error: expected ';' at end of declaration"

What should I do?

Aucun commentaire:

Enregistrer un commentaire