jeudi 7 avril 2016

C++11 in QtCreator 3.5.0 on ubuntu

Problem: QtCreator seems to not compile with C++11 standard though Config += c++11 is set in the projects .pro file.

Background: The global definition of the scoped enums are in a seperate header file global_definitions.h:

// ...
enum class dr_items { CROSSHAIR,
                  GRID,
                  LABELS,
                  DATA,
                  AMOUNT // count element
                };

This file produces a warning for every scoped enum, but no error:

/path/global_definitions.h:7: warning: scoped enums only available with -std=c++11 or -std=gnu++11
enum class dr_items { CROSSHAIR,
^

The error occurs on the first usage of the scoped enum in file oscscene.cpp:

#include "oscscene.h"
#include "global_definitions.h"

// ...

for(int i=0;i++;i<dr_items::AMOUNT){
    // ...

with the error output

 /path/oscscene.cpp:9: error: 'dr_items' is not a class or namespace
 for(int i=0;i++;i<dr_items::AMOUNT){
                   ^

Projects .pro file:

QT       += core gui
CONFIG   += c++11
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

Versions:

  • OS is xubuntu 15.10
  • QtCreator version is 3.5.0
  • Qt version is 5.4.2
  • G++ version is 5.2.1
  • Gcc version is 5.2.1
  • make is version 4.0
  • qmake is version 2.01a, but seems to refer to Using Qt version 4.8.6 in /usr/lib/x86_64-linux-gnu when called from console.

Aucun commentaire:

Enregistrer un commentaire