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
Forum Updated to NodeBB v4.3 + New Features

Qt Creator displaying warnings related to C++98

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
12 Posts 3 Posters 595 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.
  • G Offline
    G Offline
    GregB
    wrote on 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
    • 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

                      • Login

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