Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Look up table: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
Servers for Qt installer are currently down

Look up table: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cdwijs
    wrote on 19 Sept 2016, 10:03 last edited by cdwijs
    #1

    Hi All,
    I want to make a look up table, that is used in two functions in the program. The following gives these warnings. What does this warning mean, and how can I get rid of it?
    Cheers,
    Cedric
    My versions:
    Windows 7 enterprise SP1 64 bit
    Qt Creator 3.6.0 Based on Qt 5.5.1 (MSVC 2013, 32 bit)
    QT5.5, mingw492_32

    C:\somewhere\Qt-tutorials\look-up-table\mainwindow.h:21: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
         };
         ^
    C:\somewhere\Qt-tutorials\look-up-table\mainwindow.h:21: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
    
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
        const unsigned short myLut[8]=
        {
            0,      0x3f80, 0x4000, 0x4040, 0x4080, 0x40a0, 0x40c0, 0x40e0,
        };
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    
    J 1 Reply Last reply 19 Sept 2016, 10:42
    0
    • C cdwijs
      19 Sept 2016, 10:03

      Hi All,
      I want to make a look up table, that is used in two functions in the program. The following gives these warnings. What does this warning mean, and how can I get rid of it?
      Cheers,
      Cedric
      My versions:
      Windows 7 enterprise SP1 64 bit
      Qt Creator 3.6.0 Based on Qt 5.5.1 (MSVC 2013, 32 bit)
      QT5.5, mingw492_32

      C:\somewhere\Qt-tutorials\look-up-table\mainwindow.h:21: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11
           };
           ^
      C:\somewhere\Qt-tutorials\look-up-table\mainwindow.h:21: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
      
      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H
      
      #include <QMainWindow>
      
      namespace Ui {
      class MainWindow;
      }
      
      class MainWindow : public QMainWindow
      {
          Q_OBJECT
      
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
          const unsigned short myLut[8]=
          {
              0,      0x3f80, 0x4000, 0x4040, 0x4080, 0x40a0, 0x40c0, 0x40e0,
          };
      
      private:
          Ui::MainWindow *ui;
      };
      
      #endif // MAINWINDOW_H
      
      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 19 Sept 2016, 10:42 last edited by jsulm
      #2

      @cdwijs said in Look up table: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11:

      const unsigned short myLut[8]=
      {
      0, 0x3f80, 0x4000, 0x4040, 0x4080, 0x40a0, 0x40c0, 0x40e0,
      };

      Here you initialize a non-static class member directly inside the class. This is supported in C++11 standard but not before C++11. You either should move the initialization to the constructor or activate C++11 as suggested in the warning message. Put this in your .pro file:

      CONFIG += c++11
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      1/2

      19 Sept 2016, 10:03

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved