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
Qt 6.11 is out! See what's new in the release blog

Qt Creator displaying warnings related to C++98

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
13 Posts 4 Posters 2.4k Views 2 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.
  • aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on 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 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.

      JonBJ 1 Reply Last reply
      0
      • G GregB

        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.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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
        • aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 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.

          JonBJ 1 Reply Last reply
          0
          • aha_1980A aha_1980

            @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

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on 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
            • aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 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.

              JonBJ 1 Reply Last reply
              0
              • aha_1980A aha_1980

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

                Regards

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on 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
                • aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on 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 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
                    • F Offline
                      F Offline
                      f222
                      wrote on last edited by
                      #13

                      I might be digging up the post but I encountered the same issue because I had spaces in my compiler flags.

                      I am using clang-cl and in my .pro file I added includes using imsvc to avoid warning on those files like so:

                      QMAKE_CXXFLAGS += /imsvc\"C:/path with spaces /to/include/folder\"

                      Using \ before the quotes and / as path delimiter allows the code to compile as expected but it doesn't prevent the code model from being broken.

                      If I go to Tools->Debug Qt Creator -> Inspect C++ code model , under Project Parts tab in the General tab and look at the compiler flags you can see that it will split the path on the spaces and consider the parts of the path as separate flags:

                      83e25b37-b4a8-4039-b813-87b596b1db2a-image.png

                      (Example shown on Qt5 but it's the same with Qt 6)

                      1 Reply Last reply
                      0

                      • Login

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