Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator displaying warnings related to C++98
QtWS25 Last Chance

Qt Creator displaying warnings related to C++98

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
12 Posts 3 Posters 509 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.
  • G Offline
    G Offline
    GregB
    wrote on 18 Feb 2025, 21:21 last edited by
    #1

    I'm running Qt Creator 15.0.1 on Windows, and I'm getting warnings about incompatibilites with C++98. This is appearing as annotations in code editor.

    I've added the following to the .pro file, but it didn't change any behavior

    CONFIG -= c++98
    CONFIG += c++11
    CONFIG += c++17
    

    How can I get the clang code model to ignore C++98 issues?

    1 Reply Last reply
    0
    • C Christian Ehrlicher moved this topic from General and Desktop on 19 Feb 2025, 05:14
    • A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 19 Feb 2025, 08:20 last edited by
      #2

      @GregB You are currently adding both C++11 and C++17 - please choose one of them. If you use an older Qt and therefore qmake version, you might need to replace C++17 with C++1z

      Also, I doubt that CONFIG -= c++98 has any meaning, see https://doc.qt.io/qt-6/qmake-variable-reference.html#config for known variables.

      If you still encounter problems, please share the code you are getting warnings with.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GregB
        wrote on 19 Feb 2025, 15:32 last edited by
        #3

        I changed the .pro file to only contain the c++17. The warnings that I'm getting are within Qt Creator, not from the build process. Some example warnings are below:

        M:\nidb\src\nidb\modulePipeline.cpp:300: warning: 'auto' type specifier is incompatible with C++98
        M:\nidb\src\nidb\modulePipeline.cpp:300: warning: If initialization statements are incompatible with C++ standards before C++17
        M:\nidb\src\nidb\modulePipeline.cpp:1377: warning: Initialization of initializer_list object is incompatible with C++98
        M:\nidb\src\nidb\modulePipeline.cpp:1867: warning: 'auto' type specifier is incompatible with C++98
        M:\nidb\src\nidb\modulePipeline.cpp:1867: warning: If initialization statements are incompatible with C++ standards before C++17
        M:\nidb\src\nidb\modulePipeline.cpp:2188: warning: Universal character name referring to a control character is incompatible with C++98
        
        1 Reply Last reply
        0
        • A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 19 Feb 2025, 17:35 last edited by
          #4

          @GregB could you also share the relevant code lines?

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GregB
            wrote on 20 Feb 2025, 19:00 last edited by
            #5

            Line 300

            foreach (int sid, studyids) {
            

            Line 1377

            QStringList bidsflags = { "BIDS_SUBJECTDIR_UID", "BIDS_STUDYDIR_STUDYNUM" };
            

            Line 1867

            foreach (QString group, groups) {
            

            I'm not sure that the code is invalid? This code builds without warnings or error. The only issue is the warnings within Qt Creator generated by clangd within the editor. I recently upgraded my computer and reinstalled Qt Creator, and that's when I started getting the warnings. I was using 15.0.1 before, and 15.0.1 now. I must have had a setting turned off on my previous computer related to clangd, but I don't know what the setting is.

            J 1 Reply Last reply 20 Feb 2025, 20:28
            0
            • G GregB
              20 Feb 2025, 19:00

              Line 300

              foreach (int sid, studyids) {
              

              Line 1377

              QStringList bidsflags = { "BIDS_SUBJECTDIR_UID", "BIDS_STUDYDIR_STUDYNUM" };
              

              Line 1867

              foreach (QString group, groups) {
              

              I'm not sure that the code is invalid? This code builds without warnings or error. The only issue is the warnings within Qt Creator generated by clangd within the editor. I recently upgraded my computer and reinstalled Qt Creator, and that's when I started getting the warnings. I was using 15.0.1 before, and 15.0.1 now. I must have had a setting turned off on my previous computer related to clangd, but I don't know what the setting is.

              J Offline
              J Offline
              JonB
              wrote on 20 Feb 2025, 20:28 last edited by
              #6

              @GregB
              Up to you, but you could change foreach() to for ( : ), and I would guess remove the = in the middle one? Not that you have to, but these are newer constructs and I guess it's moaning about the older ones?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on 21 Feb 2025, 05:50 last edited by
                #7

                @GregB Thanks. Looking at the foreach source code there is indeed a line for (auto name = QtPrivate::qMakeForeachContainer(container); name.i != name.e; ++name.i) which is valid C++11 and higher code.

                So I think for some reason the code model does not pick up the C++17 specifier. Can you try a minimal "Hello World" style example?

                @JonB Be careful with such suggestions. Changing foreach() to range-based for requires a studies with diploma exam ;)

                Regards

                Qt has to stay free or it will die.

                J 1 Reply Last reply 21 Feb 2025, 09:55
                0
                • A aha_1980
                  21 Feb 2025, 05:50

                  @GregB Thanks. Looking at the foreach source code there is indeed a line for (auto name = QtPrivate::qMakeForeachContainer(container); name.i != name.e; ++name.i) which is valid C++11 and higher code.

                  So I think for some reason the code model does not pick up the C++17 specifier. Can you try a minimal "Hello World" style example?

                  @JonB Be careful with such suggestions. Changing foreach() to range-based for requires a studies with diploma exam ;)

                  Regards

                  J Offline
                  J Offline
                  JonB
                  wrote on 21 Feb 2025, 09:55 last edited by JonB
                  #8

                  @aha_1980 said in Qt Creator displaying warnings related to C++98:

                  @JonB Be careful with such suggestions. Changing foreach() to range-based for requires a studies with diploma exam ;)

                  If you say so! I only know that I use for instead of foreach (at least in similar cases to what the OP shows above, an int and a QString and their lists) and never had any issues?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aha_1980
                    Lifetime Qt Champion
                    wrote on 21 Feb 2025, 11:43 last edited by
                    #9

                    @JonB: You think you don't have any issues before you read the post Goodbye Q_FOREACH! I mentioned.

                    Regards

                    Qt has to stay free or it will die.

                    J 1 Reply Last reply 21 Feb 2025, 12:12
                    0
                    • A aha_1980
                      21 Feb 2025, 11:43

                      @JonB: You think you don't have any issues before you read the post Goodbye Q_FOREACH! I mentioned.

                      Regards

                      J Offline
                      J Offline
                      JonB
                      wrote on 21 Feb 2025, 12:12 last edited by
                      #10

                      @aha_1980
                      But just to round off, I thought there are no issues for the specific int-in-list and QString-in-QStringList OP's cases as shown, or are there?

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on 21 Feb 2025, 12:57 last edited by
                        #11

                        @JonB: not for the int and the QString , but probably for the corresponding lists. But for the details, you will have to read the mentioned post.

                        Qt has to stay free or it will die.

                        1 Reply Last reply
                        1
                        • G Offline
                          G Offline
                          GregB
                          wrote on 21 Feb 2025, 15:02 last edited by
                          #12

                          Thanks for the comments. So I don't think there's anything wrong with the code itself. It seems to be a configuration with Qt Creator and clangd that is ignoring the c++17 specification in the .pro file.

                          I found a previous post about this issue, and how they fixed it: https://forum.qt.io/topic/109856/incompatible-with-c-98-warnings-since-qt-creater-update/3

                          But that post is 5 years old, and none of the options they used to fix the issue exist in in the current Qt Creator.

                          1 Reply Last reply
                          0

                          2/12

                          19 Feb 2025, 08:20

                          topic:navigator.unread, 10
                          • Login

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