Using C++11 with provided binaries of Qt5.0.0 on a Mac?

  • I use the provided binaries (from downloads section) for Qt5.0.0 for my Mac. Can I use C++11, and if yes, is there something special I need to do?

  • In Qt5 I think there so no need to do anything special. In Qt4 you had to sent a flag to enable C++0x. Clang support for C++11 is pretty good, actually last time I checked it was the most complete. Just to be sure write a lambda or two, some auto identifiers and so on and see if you get errors.

    I am not a mac user, but I used Qt5 with MSVC2012 C++11 features out of the box. Should be the same for mac.

  • Yes, the problem is that I get errors!

    E.g.: if I use

    @auto x = 1;@

    I get the error:

    @/Users/username/programname/main.cpp:7: error: ISO C++ forbids declaration of 'x' with no type@

    So the word auto is NOT properly recognised with its C++11 meaning!

    Maybe I am using the wrong compiler (GCC instead of Clang)? If I go to Qt Creator ---> Preferences... ---> Build and Run ---> Kits, I have an auto-detected kit named "Desktop Qt 5.0.0 clang 64bit (SDK)" as default, but if I view its specifications, it mentions as "Compiler:" not Clang, but "GCC (x86 64bit).

  • For GCC you may still need to pass the "-std=gnu++0x" flag, provided of course your GCC version is not too ancient. I'd rather use Clang, "from the looks of it, Qt 5.0.1 will launch any day now with prebuild binaries for Clang": for mac.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.