Reconcile style of include directives across all source files.
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
Glabels Coding Style
|
||||
====================
|
||||
|
||||
This file describes the coding style used in all glabels source code. Any patches or pull requests should
|
||||
adhere to this style.
|
||||
|
||||
|
||||
Tabs vs. Spaces
|
||||
---------------
|
||||
|
||||
@@ -40,3 +44,53 @@ else
|
||||
Also applies to class and namespace declaration statements.
|
||||
|
||||
See https://en.wikipedia.org/wiki/Indent_style#Allman_style for more information.
|
||||
|
||||
|
||||
File Organization
|
||||
-----------------
|
||||
|
||||
Generally code is organized into modules. Usually a module defines a single class or a small namespace of
|
||||
functions/constants/etc. A module is defined by two files: a header file (its specification) and an
|
||||
implementation file. Header filenames have a ".h" extension and implementation filenames have a ".cpp"
|
||||
extension.
|
||||
|
||||
|
||||
### Self-contained Headers
|
||||
|
||||
Header files should be self-contained. I.e. they should not require any prerequisite includes. To enforce
|
||||
this requirement, an implementation file shall include its header file before any other includes.
|
||||
|
||||
|
||||
### Multiple Inclusion Guards
|
||||
|
||||
All header files should have an ifndef guard to prevent multiple inclusion.
|
||||
|
||||
```
|
||||
#ifndef ns_Module_h
|
||||
#define ns_Module_h
|
||||
|
||||
...
|
||||
|
||||
#endif // ns_Module_h
|
||||
```
|
||||
|
||||
### Include Directives
|
||||
|
||||
Header files should be included in the following order.
|
||||
|
||||
1. header file for this module (e.g. this would be "Foo.h" in "Foo.cpp").
|
||||
2. C system header files (preference is for the C++ version if available, e.g. <cmath> instead of <math.h>.
|
||||
3. C++ system header files (e.g. STL files)
|
||||
4. Qt header files
|
||||
5. Other libraries' header files
|
||||
6. Other glabels header files.
|
||||
|
||||
Paths used in include directives should always be relative to either the glabels source directory or an
|
||||
appropriate base directory for each library. They should NEVER include UNIX directory shortcuts such as "."
|
||||
(the current directory) or ".." (the parent directory).
|
||||
|
||||
Angle brackets ("<>") should be used for inclusion of all external header files (such as C/C++ and Qt
|
||||
header files). Double quotes should be used for all glabels header files.
|
||||
|
||||
Do not use forward declarations to any external entities. Use the appropriate include directive instead.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user