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. Should I be concerned about "is a C++11 extension"?
QtWS25 Last Chance

Should I be concerned about "is a C++11 extension"?

Scheduled Pinned Locked Moved Solved General and Desktop
c++11compiler
6 Posts 4 Posters 10.7k Views
  • 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.
  • M Offline
    M Offline
    maximo
    wrote on 22 Oct 2015, 23:08 last edited by maximo
    #1

    Newbie here

    I am seeing the following warnings during compile. It still compiles however, and seems to run okay. Should I be concerned? Should I change my code to avoid this? Will I have problems during deployment?

    In file included from ../project1/mainwindow.cpp:1:
    ../project1/mainwindow.h:65:31: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
        const int DIALOG_REGISTER = 0;
                                  ^
    ../project1/mainwindow.h:66:27: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
        const int DIALOG_HELP = 1;
                              ^
    ../project1/mainwindow.cpp:400:29: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
        for(const QString &sLine: asStyle) {
                                ^
    ../project1/mainwindow.cpp:434:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
        for (const QString &k: settings.childKeys()) {
    
    M 1 Reply Last reply 22 Oct 2015, 23:22
    0
    • M maximo
      22 Oct 2015, 23:08

      Newbie here

      I am seeing the following warnings during compile. It still compiles however, and seems to run okay. Should I be concerned? Should I change my code to avoid this? Will I have problems during deployment?

      In file included from ../project1/mainwindow.cpp:1:
      ../project1/mainwindow.h:65:31: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
          const int DIALOG_REGISTER = 0;
                                    ^
      ../project1/mainwindow.h:66:27: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
          const int DIALOG_HELP = 1;
                                ^
      ../project1/mainwindow.cpp:400:29: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
          for(const QString &sLine: asStyle) {
                                  ^
      ../project1/mainwindow.cpp:434:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
          for (const QString &k: settings.childKeys()) {
      
      M Offline
      M Offline
      mcosta
      wrote on 22 Oct 2015, 23:22 last edited by
      #2

      @maximo said:

      Should I be concerned? Should I change my code to avoid this? Will I have problems during deployment?

      The compiler is telling you that your code uses some C++11 extensions (there's a warning enabled for that).
      You have to change your code only if you want build your code with old compilers not supporting this standard. If is not the case you can also safely remove the warning flag.

      As general rule, IMO, use C++11 if you can.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 23 Oct 2015, 06:48 last edited by
        #3

        Hi

        You should always try to remove all warning. (IMO)

        do you have
        CONFIG +=C++11
        in .pro
        file ?
        (this enable c++ 11)

        Also, it think you did
        class SomeClass {
        int A=10; <---- old compilers wont allow.
        };

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on 23 Oct 2015, 14:30 last edited by
          #4

          @mrjj He said tho code build and run so C++11 is enabled. The warning is generated by some compiler option

          @maximo Which compiler are you using? Which flags do you pass to it?

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          M 1 Reply Last reply 23 Oct 2015, 15:48
          1
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 23 Oct 2015, 14:42 last edited by
            #5

            @mcosta C++11 is not enabled. The warning says that he is using a C++11 extension i.e. he's using C++03 with that feature enabled as an extension.

            The best solution to avoid this warning is to add CONFIG += C++11 to the .pro file to enable proper C++11 mode, instead of using extensions with earlier standard version (which is sadly still the default for clang and gcc).

            1 Reply Last reply
            1
            • M mcosta
              23 Oct 2015, 14:30

              @mrjj He said tho code build and run so C++11 is enabled. The warning is generated by some compiler option

              @maximo Which compiler are you using? Which flags do you pass to it?

              M Offline
              M Offline
              maximo
              wrote on 23 Oct 2015, 15:48 last edited by
              #6

              @mcosta I'm using the XCode on OSX in this case.

              1 Reply Last reply
              0

              5/6

              23 Oct 2015, 14:42

              • Login

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