summaryrefslogtreecommitdiff
path: root/README-hacking.md
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-05-31 09:24:05 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-06-01 18:52:22 +0200
commit03a6b439f6873305aa563c03cfbcc08c0aadebb1 (patch)
tree3c08049ea06c74b850c8661b1d765d9e1de9f4d1 /README-hacking.md
parent742910838e68a40b0144bed3ee8a2802709d1c42 (diff)
downloadbison-03a6b439f6873305aa563c03cfbcc08c0aadebb1.tar.gz
style: fix includes
* src/fixits.c: Follow our usual pattern. * src/scan-code.l, src/scan-gram.l, src/scan-skel.l: Prefer "" to include src/ headers. * README-hacking.md: Document the pattern.
Diffstat (limited to 'README-hacking.md')
-rw-r--r--README-hacking.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/README-hacking.md b/README-hacking.md
index af14dbf0..24bafb6a 100644
--- a/README-hacking.md
+++ b/README-hacking.md
@@ -62,6 +62,30 @@ Don't reinvent the wheel: we use gnulib, which features many components.
Actually, Bison has legacy code that we should replace with gnulib modules
(e.g., many ad hoc implementations of lists).
+#### Includes
+The `#include` directives follow an order:
+- first section for *.c files is `<config.h>`. Don't include it in header
+ files
+- then, for *.c files, the corresponding *.h file
+- then possibly the `"system.h"` header
+- then the system headers.
+ Consider headers from `lib/` like system headers (i.e., `#include
+ <verify.h>`, not `#include "verify.h"`).
+- then headers from src/ with double quotes (`#include "getargs.h"`).
+
+Keep headers sorted alphabetically in each section.
+
+See also the [Header
+files](https://www.gnu.org/software/gnulib/manual/html_node/Header-files.html)
+and the [Implementation
+files](https://www.gnu.org/software/gnulib/manual/html_node/Implementation-files.html#Implementation-files)
+nodes of the gnulib documentation.
+
+Some source files are in the build tree (e.g., `src/scan-gram.c` made from
+`src/scan-gram.l`). For them to find the headers from `src/`, we actually
+use `#include "src/getargs.h"` instead of `#include "getargs.h"`---that
+saves us from additional `-I` flags.
+
### Skeletons
We try to use the "typical" coding style for each language.