Making application run using C++14 or C++17
-
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.
-
@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. -
Hi,
It's a build flag. You build an application using one C++ standard.
It has not much to do with running your application.
-
@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.
-
@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. -
@qml.newbie just a note: before Qt 5.12 you have to give
c++1z
insteadc++17
.Regards
-
@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...
-
@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 -
@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 LLVMWhile 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.
-
Thanks much all of the repliers.