Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Making application run using C++14 or C++17
QtWS25 Last Chance

Making application run using C++14 or C++17

Scheduled Pinned Locked Moved Solved General and Desktop
c++14c++17application
11 Posts 8 Posters 20.8k 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.
  • Q Offline
    Q Offline
    qml.newbie
    wrote on 16 Jul 2019, 09:42 last edited by
    #1

    I'm trying to make an application that should be able to run using C++14 and C++17 as long as the installed compiler in the system supports both. Is adding the following config in .pro file enough to accomplish that?

    CONFIG += c++14 c++17
    

    Or I need to do something more?

    Thanks.

    K A 2 Replies Last reply 16 Jul 2019, 09:52
    0
    • Q qml.newbie
      16 Jul 2019, 09:42

      I'm trying to make an application that should be able to run using C++14 and C++17 as long as the installed compiler in the system supports both. Is adding the following config in .pro file enough to accomplish that?

      CONFIG += c++14 c++17
      

      Or I need to do something more?

      Thanks.

      K Offline
      K Offline
      koahnig
      wrote on 16 Jul 2019, 09:52 last edited by
      #2

      @qml.newbie said in Making application run using C++14 or C++17:

      CONFIG += c++14 c++17
      

      Either one should be good enough. However, I would use C++17 only which should be conform with both standards.
      Otherwise you might generate eventually an ambiguity for the compiler and yourself.

      Vote the answer(s) that helped you to solve your issue(s)

      Q 1 Reply Last reply 16 Jul 2019, 18:20
      4
      • K koahnig
        16 Jul 2019, 09:52

        @qml.newbie said in Making application run using C++14 or C++17:

        CONFIG += c++14 c++17
        

        Either one should be good enough. However, I would use C++17 only which should be conform with both standards.
        Otherwise you might generate eventually an ambiguity for the compiler and yourself.

        Q Offline
        Q Offline
        qml.newbie
        wrote on 16 Jul 2019, 18:20 last edited by
        #3

        @koahnig Does writing

        CONFIG += c++17
        

        ensures that the it conforms to the requirement of being able run using both c++14 and c++17? Shouldn't I need to mention both in order to be able to run using either 14 and 17?

        W J 2 Replies Last reply 16 Jul 2019, 19:50
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 16 Jul 2019, 19:20 last edited by
          #4

          Hi,

          It's a build flag. You build an application using one C++ standard.

          It has not much to do with running your application.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • Q qml.newbie
            16 Jul 2019, 18:20

            @koahnig Does writing

            CONFIG += c++17
            

            ensures that the it conforms to the requirement of being able run using both c++14 and c++17? Shouldn't I need to mention both in order to be able to run using either 14 and 17?

            W Offline
            W Offline
            wrosecrans
            wrote on 16 Jul 2019, 19:50 last edited by
            #5

            @qml.newbie All C++14 code should build just fine with a C++17 toolchain. So if you want to run with either, you should stick to the older spec. Building as c++14 will make sure you aren't using any features that are only available in 17.

            1 Reply Last reply
            3
            • F Offline
              F Offline
              fcarney
              wrote on 16 Jul 2019, 20:02 last edited by fcarney
              #6

              @qml-newbie
              It might also be worth knowing what some features are supported or not supported by a compiler. Qt has defaults for using quite a few compilers. gcc, mingw, msvc, whatever mac uses, etc. At my workplace we have standardized on gcc and mingw for maximum compatibility on our platforms.

              C++ Compiler Support

              C++ is a perfectly valid school of magic.

              J 1 Reply Last reply 17 Jul 2019, 05:03
              3
              • Q qml.newbie
                16 Jul 2019, 09:42

                I'm trying to make an application that should be able to run using C++14 and C++17 as long as the installed compiler in the system supports both. Is adding the following config in .pro file enough to accomplish that?

                CONFIG += c++14 c++17
                

                Or I need to do something more?

                Thanks.

                A Offline
                A Offline
                aha_1980
                Lifetime Qt Champion
                wrote on 17 Jul 2019, 04:21 last edited by
                #7

                @qml.newbie just a note: before Qt 5.12 you have to give c++1z instead c++17.

                Regards

                Qt has to stay free or it will die.

                1 Reply Last reply
                2
                • Q qml.newbie
                  16 Jul 2019, 18:20

                  @koahnig Does writing

                  CONFIG += c++17
                  

                  ensures that the it conforms to the requirement of being able run using both c++14 and c++17? Shouldn't I need to mention both in order to be able to run using either 14 and 17?

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 17 Jul 2019, 04:23 last edited by
                  #8

                  @qml.newbie said in Making application run using C++14 or C++17:

                  Shouldn't I need to mention both in order to be able to run using either 14 and 17?

                  No, C++17 standard contains C++14 already...

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  4
                  • F fcarney
                    16 Jul 2019, 20:02

                    @qml-newbie
                    It might also be worth knowing what some features are supported or not supported by a compiler. Qt has defaults for using quite a few compilers. gcc, mingw, msvc, whatever mac uses, etc. At my workplace we have standardized on gcc and mingw for maximum compatibility on our platforms.

                    C++ Compiler Support

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 17 Jul 2019, 05:03 last edited by J.Hilk
                    #9

                    @fcarney said in Making application run using C++14 or C++17:

                    whatever mac uses

                    FYI: Clang that's at least the one you use for the precompiled Qt libs.
                    Technically, you could also go with GCC or LLVM


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    S 1 Reply Last reply 17 Jul 2019, 06:19
                    0
                    • J J.Hilk
                      17 Jul 2019, 05:03

                      @fcarney said in Making application run using C++14 or C++17:

                      whatever mac uses

                      FYI: Clang that's at least the one you use for the precompiled Qt libs.
                      Technically, you could also go with GCC or LLVM

                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 17 Jul 2019, 06:19 last edited by
                      #10

                      @J.Hilk said in Making application run using C++14 or C++17:

                      @fcarney said in Making application run using C++14 or C++17:

                      whatever mac uses

                      FYI: Clang that's at least the one you use for the precompiled Qt libs.
                      Technically, you could also go with GCC or LLVM

                      While true, Qt officially only supports the clang version provided through Xcode. Also, you can still find gcc when Xcode is installed but it's a link to clang kept for building old projects.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • Q Offline
                        Q Offline
                        qml.newbie
                        wrote on 18 Jul 2019, 16:51 last edited by
                        #11

                        Thanks much all of the repliers.

                        1 Reply Last reply
                        0

                        5/11

                        16 Jul 2019, 19:50

                        • Login

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