Making application run using C++14 or C++17
-
wrote on 16 Jul 2019, 09:42 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.
-
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.
wrote on 16 Jul 2019, 09:52 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. -
@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.wrote on 16 Jul 2019, 18:20 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?
-
Hi,
It's a build flag. You build an application using one C++ standard.
It has not much to do with running your application.
-
@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?
wrote on 16 Jul 2019, 19:50 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.
-
wrote on 16 Jul 2019, 20:02 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. -
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 just a note: before Qt 5.12 you have to give
c++1z
insteadc++17
.Regards
-
@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?
@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...
-
@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.@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 -
@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.
-
wrote on 18 Jul 2019, 16:51 last edited by
Thanks much all of the repliers.
2/11