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?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
16 Posts 3 Posters 2.7k 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on 11 Jan 2023, 16:24 last edited by
    #3

    I've tried this, no change. Or is -= not supposed to work here?

    QMAKE_CXXFLAGS -= -std=c++2a
    QMAKE_CXXFLAGS += -std=c++2b
    
    J 1 Reply Last reply 11 Jan 2023, 16:28
    0
    • V Violet Giraffe
      11 Jan 2023, 16:24

      I've tried this, no change. Or is -= not supposed to work here?

      QMAKE_CXXFLAGS -= -std=c++2a
      QMAKE_CXXFLAGS += -std=c++2b
      
      J Online
      J Online
      JoeCFD
      wrote on 11 Jan 2023, 16:28 last edited by JoeCFD 1 Nov 2023, 16:33
      #4

      @Violet-Giraffe you are right. It will not help. I was wrong.
      https://stackoverflow.com/questions/36650216/how-to-remove-alter-default-cflags-in-qmake
      there are also debug ones.
      https://doc.qt.io/qt-6/qmake-variable-reference.html

      1 Reply Last reply
      1
      • V Offline
        V Offline
        Violet Giraffe
        wrote on 11 Jan 2023, 17:46 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 =?

        J 1 Reply Last reply 11 Jan 2023, 17:48
        0
        • V Violet Giraffe
          11 Jan 2023, 17:46

          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 =?

          J Online
          J Online
          JoeCFD
          wrote on 11 Jan 2023, 17:48 last edited by JoeCFD 1 Nov 2023, 17:52
          #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 11 Jan 2023, 18:23 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.

            J 1 Reply Last reply 11 Jan 2023, 21:28
            0
            • V Violet Giraffe
              11 Jan 2023, 18:23

              @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.

              J Online
              J Online
              JoeCFD
              wrote on 11 Jan 2023, 21:28 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
              • C Offline
                C Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on 11 Jan 2023, 23:46 last edited by Chris Kawa 1 Nov 2023, 23:47
                #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 12 Jan 2023, 12:41
                0
                • C Chris Kawa
                  11 Jan 2023, 23:46

                  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 12 Jan 2023, 12:41 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?

                  C 1 Reply Last reply 12 Jan 2023, 13:14
                  0
                  • V Violet Giraffe
                    12 Jan 2023, 12:41

                    @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?

                    C Offline
                    C Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on 12 Jan 2023, 13:14 last edited by Chris Kawa 1 Dec 2023, 14:03
                    #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 12 Jan 2023, 21:08 last edited by Violet Giraffe 1 Dec 2023, 21:08
                      #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
                      • C Offline
                        C Offline
                        Chris Kawa
                        Lifetime Qt Champion
                        wrote on 12 Jan 2023, 22:03 last edited by Chris Kawa 1 Dec 2023, 22:10
                        #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 12 Jan 2023, 22:31 last edited by
                          #14

                          I see, thank you!

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            Violet Giraffe
                            wrote on 13 Jan 2023, 21:31 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 5 Feb 2023, 14:07
                            0
                            • V Violet Giraffe
                              13 Jan 2023, 21:31

                              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 5 Feb 2023, 14:07 last edited by Violet Giraffe 2 May 2023, 14:07
                              #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