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. qmake: how to override -std=... compiler flag?
Forum Updated to NodeBB v4.3 + New Features

qmake: how to override -std=... compiler flag?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
16 Posts 3 Posters 3.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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #5

    Thanks! But should -= work with QMAKE_CXXFLAGS_RELEASE? Because for me it made no difference either (+= works, though). Do I have to reset everything with =?

    JoeCFDJ 1 Reply Last reply
    0
    • V Violet Giraffe

      Thanks! But should -= work with QMAKE_CXXFLAGS_RELEASE? Because for me it made no difference either (+= works, though). Do I have to reset everything with =?

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #6

      @Violet-Giraffe As you tried. -= was done earlier. but c++2a was added later. -= does not help.
      From the last post in the link QMAKE_CXXFLAGS_RELEASE has only =. I guess you simply add what you need there.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #7

        @JoeCFD said in qmake: how to override -std=... compiler flag?:
        Thanks, but that doesn't work either, unfortunately. It made no difference to the command line at all.

        JoeCFDJ 1 Reply Last reply
        0
        • V Violet Giraffe

          @JoeCFD said in qmake: how to override -std=... compiler flag?:
          Thanks, but that doesn't work either, unfortunately. It made no difference to the command line at all.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #8

          @Violet-Giraffe Just tested it. True no help. You may take a look at the source code of qmake
          https://github.com/qt/qtbase/tree/dev/qmake

          1 Reply Last reply
          0
          • Chris KawaC Offline
            Chris KawaC Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by Chris Kawa
            #9

            These are the values for the standard versions I get on GCC (MinGW 11.2). Not passing any compiler specific flags to QMAKE_CXXFLAGS.

            CONFIG switch Compiler flag
            CONFIG += c++17 -std=gnu++1z
            CONFIG += c++20 -std=gnu++2a
            CONFIG += c++latest -std=gnu++2b
            CONFIG += c++17 strict_c++ -std=c++1z
            CONFIG += c++20 strict_c++ -std=c++2a
            CONFIG += c++latest strict_c++ -std=c++2b
            V 1 Reply Last reply
            0
            • Chris KawaC Chris Kawa

              These are the values for the standard versions I get on GCC (MinGW 11.2). Not passing any compiler specific flags to QMAKE_CXXFLAGS.

              CONFIG switch Compiler flag
              CONFIG += c++17 -std=gnu++1z
              CONFIG += c++20 -std=gnu++2a
              CONFIG += c++latest -std=gnu++2b
              CONFIG += c++17 strict_c++ -std=c++1z
              CONFIG += c++20 strict_c++ -std=c++2a
              CONFIG += c++latest strict_c++ -std=c++2b
              V Offline
              V Offline
              Violet Giraffe
              wrote on last edited by
              #10

              @Chris-Kawa, thanks, but unfortunately that's not a good solution - for Qt 5.15 c++latest is still c++2a. Yes, I could switch to Qt 6 just to get this working, but I don't want to do that right now.
              This problem comes up every single time there is a new level of C++ support in GCC / clang that needs to be enabled. Is there really no solution, no variable in the qmake project that I can manipulate to get this to work?

              Chris KawaC 1 Reply Last reply
              0
              • V Violet Giraffe

                @Chris-Kawa, thanks, but unfortunately that's not a good solution - for Qt 5.15 c++latest is still c++2a. Yes, I could switch to Qt 6 just to get this working, but I don't want to do that right now.
                This problem comes up every single time there is a new level of C++ support in GCC / clang that needs to be enabled. Is there really no solution, no variable in the qmake project that I can manipulate to get this to work?

                Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by Chris Kawa
                #11

                @Violet-Giraffe Right. Well, the CONFIG page for Qt5 says it should support c++2b, but when I tried it with 5.15.2 it doesn't add anything, so that's a bummer.

                I added -std=c++2b directly in the mkspec config and that works ok, but it seems the project using Qt 5.15.2 doesn't compile with C++2b. A bunch of compilation errors occur within Qt's headers . I wonder it that's something that is fixed down the 5.15.x line or Qt5 simply doesn't work with C++2b and that's the reason it's not exposed in qmake.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  Violet Giraffe
                  wrote on last edited by Violet Giraffe
                  #12

                  That's odd, I don't understand why it would give you errors, will try. It's not a real solution, though, it's a hack, because it requires modifying the Qt installation. Not something I look forward to in CI scripts (e. g. Github Actions).

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by Chris Kawa
                    #13

                    I use warnings as errors, so a long list of them are really just warnings, like deprecated bitwise operations between different enums, but there are also hard errors, e.g. in QtConcurrent around some templated constructors. Maybe related to some CTAD changes that are introduced in C++23, but I haven't investigated further.

                    EDIT: Yeah, it's this one: QTBUG-91909. Fixed in later versions but not the current open source 5.15.2 available through installer. There's probably more like that.

                    1 Reply Last reply
                    2
                    • V Offline
                      V Offline
                      Violet Giraffe
                      wrote on last edited by
                      #14

                      I see, thank you!

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        Violet Giraffe
                        wrote on last edited by Violet Giraffe
                        #15

                        i accidentally found a very funny workaround: I spelled c++_latest, which is a mistake because the underscore shouldn't be there, and voila - qmake did not add any -std= option at all! So I was free to then add my coveted c++2b. I have not tested whether this works with Qt 6, though.

                        V 1 Reply Last reply
                        0
                        • V Violet Giraffe

                          i accidentally found a very funny workaround: I spelled c++_latest, which is a mistake because the underscore shouldn't be there, and voila - qmake did not add any -std= option at all! So I was free to then add my coveted c++2b. I have not tested whether this works with Qt 6, though.

                          V Offline
                          V Offline
                          Violet Giraffe
                          wrote on last edited by Violet Giraffe
                          #16

                          @Violet-Giraffe said in qmake: how to override -std=... compiler flag?:

                          i accidentally found a very funny workaround: I spelled c++_latest, which is a mistake because the underscore shouldn't be there, and voila - qmake did not add any -std= option at all! So I was free to then add my coveted c++2b. I have not tested whether this works with Qt 6, though.

                          This doesn't work on Mac, only on Linux. On Mac qmake still inserts -std=c++11 after my own flags. Argh!!!

                          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