Skip to content

Commit 71fa9c6

Browse files
lundibundidanielleadams
authored andcommitted
doc: add note regarding file structure in src/README.md
Refs: #34944 (comment) Co-authored-by: Anna Henningsen <[email protected]> PR-URL: #35000 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
1 parent d6bd78f commit 71fa9c6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,30 @@ the [event loop][] and other operation system abstractions to Node.js.
3838

3939
There is a [reference documentation for the libuv API][].
4040

41+
## File structure
42+
43+
The Node.js C++ files follow this structure:
44+
45+
The `.h` header files contain declarations, and sometimes definitions that don’t
46+
require including other headers (e.g. getters, setters, etc.). They should only
47+
include other `.h` header files and nothing else.
48+
49+
The `-inl.h` header files contain definitions of inline functions from the
50+
corresponding `.h` header file (e.g. functions marked `inline` in the
51+
declaration or `template` functions). They always include the corresponding
52+
`.h` header file, and can include other `.h` and `-inl.h` header files as
53+
needed. It is not mandatory to split out the definitions from the `.h` file
54+
into an `-inl.h` file, but it becomes necessary when there are multiple
55+
definitions and contents of other `-inl.h` files start being used. Therefore, it
56+
is recommended to split a `-inl.h` file when inline functions become longer than
57+
a few lines to keep the corresponding `.h` file readable and clean. All visible
58+
definitions from the `-inl.h` file should be declared in the corresponding `.h`
59+
header file.
60+
61+
The `.cc` files contain definitions of non-inline functions from the
62+
corresponding `.h` header file. They always include the corresponding `.h`
63+
header file, and can include other `.h` and `-inl.h` header files as needed.
64+
4165
## Helpful concepts
4266

4367
A number of concepts are involved in putting together Node.js on top of V8 and

0 commit comments

Comments
 (0)