Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    c++11 compiler
    4
    6
    9023
    Loading More Posts
    • 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
      maximo last edited by maximo

      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 Reply Quote 0
      • M
        mcosta @maximo last edited by

        @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 Reply Quote 0
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          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 Reply Quote 0
          • M
            mcosta last edited by

            @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 Reply Quote 1
            • Chris Kawa
              Chris Kawa Moderators last edited by

              @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 Reply Quote 1
              • M
                maximo @mcosta last edited by

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post