[Development] C++11 for Examples

Blasche Alexander alexander.blasche at theqtcompany.com
Mon Mar 2 17:20:29 CET 2015


Hi,

the astute readers who have followed and endured some of the long C++11 related threads on this mailing list may have noticed that one important suggestion was made with regards to future C++11 usage in Qt.

The suggestion was/is to permit the usage of C++11 in Qt examples. Here is a concrete set of suggestions to address the open issues and consequences:

1.) Use C++11 for examples starting with Qt 5.6

2.) Coding convention for C++11 constructs and set of permitted features: 
https://wiki.qt.io/index.php?title=Coding_Conventions#Conventions_for_C.2B.2B11_usage

3.) The coding conventions above imply a set of base line compilers for Qt examples (gcc 4.5+, VS2010+, OSX 10.7+)

4.) Don't use any of the macros such as Q_DECL_OVERRIDE (assuming that override would be part of the accepted set of features). The examples should be clean C++11 code.

The suggestions 2 & 3 above are based on current Qt Creator policy.

You might ask why just lambda and auto as suggestion? The biggest problem is that various compilers have differing support for C++11. Therefore each new C++11 feature is likely to enforce even stricter/newer example compilers. If you want your pet C++11 feature please ensure that the compilers in item 3 support this feature. Alternatively we may discuss whether the suggested list of "example base line" compilers is correct. 

Since

contains(QT_CONFIG, c++11)

is a very coarse qmake check for a given set of C++11 features it is unlikely to be useful to serve as enabler for converted examples. Workarounds might be to not compile examples on unsupported platforms in the CI anymore or we define a new qmake flag that precisely covers the required set of C++ features. The latter would certainly be more user friendly.

Comments, suggestions and desires?

--
Alex



More information about the Development mailing list