Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    c++14 c++17 application
    8
    11
    12193
    Loading More Posts
    • 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
      qml.newbie last edited by

      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 aha_1980 2 Replies Last reply Reply Quote 0
      • K
        koahnig @qml.newbie last edited by

        @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 Reply Quote 4
        • Q
          qml.newbie @koahnig last edited by

          @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 jsulm 2 Replies Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 2
            • W
              wrosecrans @qml.newbie last edited by

              @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 Reply Quote 3
              • fcarney
                fcarney last edited by fcarney

                @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.Hilk 1 Reply Last reply Reply Quote 3
                • aha_1980
                  aha_1980 Lifetime Qt Champion @qml.newbie last edited by

                  @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 Reply Quote 2
                  • jsulm
                    jsulm Lifetime Qt Champion @qml.newbie last edited by

                    @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 Reply Quote 4
                    • J.Hilk
                      J.Hilk Moderators @fcarney last edited by J.Hilk

                      @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

                      Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

                      SGaist 1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion @J.Hilk last edited by

                        @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 Reply Quote 1
                        • Q
                          qml.newbie last edited by

                          Thanks much all of the repliers.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post