darenw
26th February 2016, 08:05
I'm trying to use C++14 (or C++11) in a small Qt4 application. I have, for example,
auto layout = new QHBoxLayout;
instead of the usual
QHBoxLayout *layout = new QHBoxLayout;
Compiling with g++ (Arch Linux, upgraded about a month ago) gives errors (copied by hand; copy/paste not working with my xterm today):
x.cpp:31:2: warning: 'auto' changes meaning in C++11; please remove it
auto layout = new QHBoxLayout;
^
x.cpp:31:7: error: 'layout' does not name a type
auto layout = new QHBoxLayout;
^
Perhaps there's something wrong with the way I wrote the line with 'auto', or perhaps Qt4 isn't compatible with using C++11. I did find documentation for qmake (I'm actually using qmake-qt4) and the CONFIG variable, so I put this into the .pro file:
CONFIG += c++11
Is there more I need to do? Am I a fool to try using C++11 or C++14?
Does Qt5 deal with C++11 the same way as Qt4?
auto layout = new QHBoxLayout;
instead of the usual
QHBoxLayout *layout = new QHBoxLayout;
Compiling with g++ (Arch Linux, upgraded about a month ago) gives errors (copied by hand; copy/paste not working with my xterm today):
x.cpp:31:2: warning: 'auto' changes meaning in C++11; please remove it
auto layout = new QHBoxLayout;
^
x.cpp:31:7: error: 'layout' does not name a type
auto layout = new QHBoxLayout;
^
Perhaps there's something wrong with the way I wrote the line with 'auto', or perhaps Qt4 isn't compatible with using C++11. I did find documentation for qmake (I'm actually using qmake-qt4) and the CONFIG variable, so I put this into the .pro file:
CONFIG += c++11
Is there more I need to do? Am I a fool to try using C++11 or C++14?
Does Qt5 deal with C++11 the same way as Qt4?