Skip to content

Commit 93c9d15

Browse files
committed
Update CONTRIBUTING.md (after our new C coding style guide)
Part of CONTRIBUTING.md is redundant now, AtomVM C Coding Style guide is a replacement (that also covers additional topics). Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent 3cbad66 commit 93c9d15

File tree

1 file changed

+1
-98
lines changed

1 file changed

+1
-98
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -66,107 +66,10 @@ All source code modules should include copyright headers that are formatted for
6666

6767
### C Code
6868

69-
C source code style is enforced with [`clang-format-16`](https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormat.html). To automatically fix a file, run:
69+
C source code follows the [AtomVM C Coding Style Guide (AVMCCS)](C_CODING_STYLE.md). The style is enforced with [`clang-format-16`](https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormat.html). To automatically fix a file, run:
7070

7171
clang-format-16 --style=file -i file.c
7272

73-
#### Indentation
74-
75-
* [K&R indentation and braces style](https://en.wikipedia.org/wiki/Indentation_style#K&R_style)
76-
* [Mandatory braces](https://en.wikipedia.org/wiki/Indentation_style#Variant:_mandatory_braces)
77-
* 4 space indentation (no tabs)
78-
79-
Good:
80-
81-
void f(bool reverse)
82-
{
83-
if (reverse) {
84-
puts("!dlroW olleH");
85-
} else {
86-
puts("Hello world");
87-
}
88-
}
89-
90-
Bad:
91-
92-
void f(bool reverse) {
93-
if (reverse)
94-
puts ("!dlroW olleH");
95-
else
96-
puts ("Hello world");
97-
}
98-
99-
#### Naming Conventions
100-
101-
* Struct names are PascalCase (e.g. `Context`)
102-
* Scalar types are lower case (e.g. `term`)
103-
* All other names (e.g. functions and variables) are snake_case (e.g. `term_is_integer`)
104-
* Always prefix exported function names with the module in which they are defined (e.g. `term_is_nil`, `term_is_integer`, `context_new`, `context_destroy`)
105-
106-
#### Other Coding Conventions
107-
108-
* Pointers (`*`) should be with the variable name rather than with the type (e.g. `char *name`, not
109-
`char* name`)
110-
* Avoid long lines, use intermediate variables with meaningful names.
111-
* Function definitions should be separated by 1 empty line
112-
113-
Function declarations should be structured as follows:
114-
115-
func(main_input, additional_inputs, main_output, additional_outputs, opts, [context])
116-
117-
where `context` is a context structure (such as `Context` or `GlobalContext`).
118-
119-
Any functions that are not exported should be qualified with the `static` keyword.
120-
121-
Functions that return booleans should be named `is_something` (or possibly `module_is_something`, if the function is exported).
122-
123-
C header modules (`.h`) should be organized as follows:
124-
125-
+-------------------
126-
| Copyright Header
127-
|
128-
| #ifdef MODULE__H__
129-
| #define MODULE__H__
130-
|
131-
| #ifdef __cplusplus
132-
| extern "C" {
133-
| #endif
134-
|
135-
| #includes (alphabetical)
136-
|
137-
| #defines
138-
|
139-
| type definitions
140-
|
141-
| function declarations
142-
|
143-
| #ifdef __cplusplus
144-
| }
145-
| #endif
146-
|
147-
| #endif
148-
+-------------------
149-
module.h
150-
151-
C source modules (`.c`) should be organized as follows:
152-
153-
+-------------------
154-
| Copyright Header
155-
|
156-
| #includes (alphabetical)
157-
|
158-
| #defines
159-
|
160-
| type definitions
161-
|
162-
| forward declarations (only if necessary)
163-
|
164-
| function definitions
165-
| dependent static functions first
166-
| exported functions and entrypoints last
167-
+-------------------
168-
module.c
169-
17073
#### Documentation
17174

17275
[Doxygen Javadoc style](https://www.doxygen.nl/manual/docblocks.html) code comments will be picked up and added to the documentation. Changes will automatically be added to the [libAtomVM Source Files](https://doc.atomvm.org/main/apidocs/libatomvm/index.html#libatomvm-source-files) and the [libAtomVM Index](https://doc.atomvm.org/main/apidocs/libatomvm/index.html#libatomvm-index). But to have `Data Structures`, `Types`, `MACROS`, and `Functions` appear in the correct C Library APIs section the corresponding entries must be added to the similarly named `*.rst` files in the `AtomVM/doc/src/apidocs/libatomvm/` directory. The exact names of the files that need to be altered are: `data_structures.rst`, `functions.rst`, `macros.rst`, and `types.rst`. The other files in the directory handle auto`generated content and do not need to be altered.

0 commit comments

Comments
 (0)