How right set using both C++11 and C++14 new features?
-
In my pro- file I added such lines:
CONFIG += c++11 CONFIG += c++14
On the other hand, C ++ 14 is a later standard, and it is probably necessary to write only:
CONFIG += c++14
How right?
And why is it not possible to indicate support for the new features of the C++17? -
@AlekseyB said in How right set using both C++11 and C++14 new features?:
CONFIG += c++14
is enough.
"And why is it not possible to indicate support for the new features of the C++17?" - why is it not possible? Does your compiler support C++17? -
@jsulm said in How right set using both C++11 and C++14 new features?:
why is it not possible? Does your compiler support C++17?
Yes, I use GCC and Intel compiler: http://en.cppreference.com/w/cpp/compiler_support
In this article http://doc.qt.io/qt-5/qmake-variable-reference.html#config I'm not found option
CONFIG += c++17
-
You can use c++1z as option or simply add the appropriate compiler options directly to CXXFLAGS
-
@Christian-Ehrlicher said in How right set using both C++11 and C++14 new features?:
You can use c++1z as option or simply add the appropriate compiler options directly to CXXFLAGS
Сan you write a specific line for the pro- file?
-
@AlekseyB Here it is, however keep in mind C++17 support is super experimental in gcc at least. I would be careful relying on it.
QMAKE_CXXFLAGS += -std=c++1z
From the help on gcc:
c++1z The next revision of the ISO C++ standard, tentatively planned for 2017. Support is highly experimental, and will almost certainly change in incompatible ways in future releases.
-
@ambershark said in How right set using both C++11 and C++14 new features?:
QMAKE_CXXFLAGS += -std=c++1z
Thank you!
I found that this line is also valid for the Intel compiler: https://software.intel.com/en-us/articles/c17-features-supported-by-intel-c-compilerDo I need if there is a line:
QMAKE_CXXFLAGS + = -std = c ++ 1z
leave a line
CONFIG + = c ++ 14
because these settings are set in different sections?
-
This post is deleted!
-
@AlekseyB said in How right set using both C++11 and C++14 new features?:
Do I need if there is a line:
QMAKE_CXXFLAGS + = -std = c ++ 1zleave a line
CONFIG + = c ++ 14You don't need the CONFIG line if you are using the QMAKE_CXXFLAGS line. They both do similar things. Using CONFIG will just have Qt set the proper setting for you based on which compiler you are using. The -std=c++1z is for gcc and would not work on say MSVC's compiler. So you need to be aware of that if you intend to compile for other platforms. That's the benefit of using CONFIG for your c++ setting.
Also side note, you can't use spaces like you do in
-std = c++1z
it won't work. It has to be-std=c++1z
. -
Thank you!
-std=c++1x
also suitable for Intel compiler. I use only these two compilers, without going over to the side of evil :)
-
@AlekseyB said in How right set using both C++11 and C++14 new features?:
without going over to the side of evil :)
Haha nice! Me too, I try to avoid the evil side. ;)