Browse Source

Merge pull request #8748 from Chocobo1/header

Clarify header inclusion order
adaptive-webui-19844
Mike Tzou 7 years ago committed by GitHub
parent
commit
827d8c0dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 63
      CODING_GUIDELINES.md

63
CODING_GUIDELINES.md

@ -232,36 +232,69 @@ class MyClass @@ -232,36 +232,69 @@ class MyClass
```
### 7. Header inclusion order. ###
The headers should be placed in the following order:
The headers should be placed in the following group order:
1. Module header (in .cpp)
2. System/Qt/Boost etc. headers (split in subcategories if you have many).
3. Application headers, starting from *Base* headers.
2. C++ Standard Library headers
3. System headers
4. Boost library headers
5. Libtorrent headers
6. Qt headers
7. qBittorrent own headers, starting from *base* headers.
The headers should be ordered alphabetically within each group.
If there are conditionals for the same header group, then put them at the bottom of the respective group.
If there are conditionals for the different header groups, then put them above of the "qBittorrent own headers" group.
One exception is the header containing the library version (for example, QtGlobal), this particular header isn't constrained by the aforementioned order.
The headers should be ordered alphabetically within each group (subgroup).<br/>
<br/>
Example:
```c++
// examplewidget.cpp
// file: examplewidget.cpp
// Module header
#include "examplewidget.h"
#include <cmath>
// exceptions, headers containing version number
#include <boost/version.hpp>
#include <libtorrent/version.hpp>
#include <QtGlobal>
// C++ Standard Library headers
#include <cstdio>
#include <QDateTime>
#include <QList>
#ifdef Q_OS_WIN // conditional
#include <cmath>
#endif
// System headers
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
// Boost library headers
#include <boost/circular_buffer.hpp>
// Libtorrent headers
#include <libtorrent/session.hpp>
// Qt headers
#include <QString>
#include <QUrl>
#include <libtorrent/version.hpp>
#ifdef Q_OS_MAC // conditional
#include <QFont>
#endif
// conditional for the different header groups
#if LIBTORRENT_VERSION_NUM >= 10100
#include <memory>
#include <QElapsedTimer>
#endif
// qBittorrent own headers
#include "base/bittorrent/infohash.h"
#include "base/bittorrent/session.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "anothermodule.h"
#include "ui_examplewidget.h"
```
### 8. Include guard. ###

Loading…
Cancel
Save