summaryrefslogtreecommitdiff
path: root/CODING_STYLE
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-05-29 20:12:17 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-29 20:12:17 +0200
commit1811232c4cc5d93cb02d93ed448a712e88e30868 (patch)
treef053a03e31e4ef3a315260677f8f451836f62899 /CODING_STYLE
parent62f908b53c0e4598c962c88ad44fb31d64155b2e (diff)
CODING_STYLE: document order in which to #include headers
Diffstat (limited to 'CODING_STYLE')
-rw-r--r--CODING_STYLE21
1 files changed, 21 insertions, 0 deletions
diff --git a/CODING_STYLE b/CODING_STYLE
index 91f09e80a8..bdec988ce6 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -292,3 +292,24 @@
- When returning a return code from main(), please preferably use
EXIT_FAILURE and EXIT_SUCCESS as defined by libc.
+
+- The order in which header files are included doesn't matter too
+ much. However, please try to include the headers of external
+ libraries first (these are all headers enclosed in <>), followed by
+ the headers of our own public headers (these are all headers
+ starting with "sd-"), internal utility libraries from src/shared/,
+ followed by the headers of the specific component. Or in other
+ words:
+
+ #include <stdio.h>
+ #include "sd-daemon.h"
+ #include "util.h"
+ #include "frobnicator.h"
+
+ Where stdio.h is a public glibc API, sd-daemon.h is a public API of
+ our own, util.h is a utility library header from src/shared, and
+ frobnicator.h is an placeholder name for any systemd component. The
+ benefit of following this ordering is that more local definitions
+ are always defined after more global ones. Thus, our local
+ definitions will never "leak" into the global header files, possibly
+ altering their effect due to #ifdeffery.