Skip to content

Commit 9c3bbe3

Browse files
committed
CODING_CONVENTIONS: enable C syntax highlighting
1 parent 5c1aa5a commit 9c3bbe3

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

CODING_CONVENTIONS.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ of recognised exceptions where we can (or even must) rely on extensions include:
8585
* Type definitions (using `typedef`) always end on "_t".
8686
* If a typedef is used for a struct, it has to be specified at the struct
8787
definition (i.e., not as a separate line). E.g.:
88-
```
88+
```c
8989
typedef struct {
9090
uint8_t a;
9191
uint8_t b;
9292
} foobar_t;
9393
```
9494
* Use of a separate line typedef for structs is allowed for forward
9595
declarations, e.g.,
96-
```
96+
```c
9797
typedef struct mystruct mystruct_t;
9898
[...]
9999
struct mystruct {
@@ -149,15 +149,15 @@ of recognised exceptions where we can (or even must) rely on extensions include:
149149

150150
* Names of all public functions and variables must start with the name of the
151151
corresponding library, e.g.:
152-
```
152+
```c
153153
thread_getpid(void);
154154
hwtimer_init_comp(uint32_t fcpu);
155155
int transceiver_pid;
156156
```
157157
* Private functions and variables do NOT have this library prefix.
158158
* Do NOT use CamelCase. Function, variable and file names as well as enums,
159159
structs or typedefs are written in lowercase with underscores.
160-
```
160+
```c
161161
/* instead of: */
162162
void CamelCaseNamedFunction(int camelCaseNamedVar);
163163
@@ -178,7 +178,7 @@ of recognised exceptions where we can (or even must) rely on extensions include:
178178
`do`-statement, it goes into the same line.
179179
* Use curly braces even for one-line blocks. This improves debugging and later
180180
additions.
181-
```
181+
```c
182182
/* instead of: */
183183
if (debug) println("DEBUG");
184184
else println("DEBUG ELSE");
@@ -202,7 +202,7 @@ indent when entering conditional compilation using `#if`/`#ifdef`/`#ifndef`
202202
(except for the include guard, which does not add to the indent). Treat indent
203203
for C language statements and C preprocessor directives independently.
204204
205-
```
205+
```c
206206
/* BAD: */
207207
#if XOSC1
208208
#define XOSC XOSC1
@@ -213,7 +213,7 @@ for C language statements and C preprocessor directives independently.
213213
#endif /* XOSC1/XOSC2 */
214214
```
215215

216-
```
216+
```c
217217
/* GOOD: */
218218
#if XOSC1
219219
# define XOSC XOSC1
@@ -224,7 +224,7 @@ for C language statements and C preprocessor directives independently.
224224
#endif
225225
```
226226

227-
```
227+
```c
228228
/* BAD: */
229229
void init_foo(uint32_t param)
230230
{
@@ -243,7 +243,7 @@ void init_foo(uint32_t param)
243243
}
244244
```
245245
246-
```
246+
```c
247247
/* GOOD: */
248248
void init_foo(uint32_t param)
249249
{
@@ -349,7 +349,7 @@ Note: these rules will be enforced by the CI.
349349
* C Header files should be always wrapped for C++ compatibility to prevent
350350
issues with name mangling, i.e. mark all the containing functions and
351351
definitions as `extern "C"`
352-
``` C
352+
```c
353353
#ifdef __cplusplus
354354
extern "C" {
355355
#endif
@@ -368,22 +368,22 @@ extern "C" {
368368

369369
* Absolute values must be specified as macros or enums, not as literals, i.e.
370370
instead of
371-
```
371+
```c
372372
int timeout = 7 * 1000000;
373373
```
374374
write
375-
```
375+
```c
376376
int timeout = TIMEOUT_INTERVAL * USEC_PER_SEC;
377377
```
378378
## Comments
379379
* All comments should be written as C-style comments.
380380

381381
E.g:
382-
```
382+
```c
383383
/* This is a C-style comment */
384384
```
385385
Wrong:
386-
```
386+
```c
387387
// C++ comment here
388388
```
389389

@@ -398,7 +398,7 @@ Wrong:
398398

399399
An exemplary doxygen documentation in a header file can look like this.
400400

401-
```
401+
```c
402402
/*
403403
* SPDX-FileCopyrightText: 2014 Peter Schmerzl <[email protected]>
404404
* SPDX-License-Identifier: LGPL-2.1-only
@@ -440,7 +440,7 @@ notices tend to vary depending on the author, making it difficult to parse
440440
automatically and reliably.
441441
442442
Old Style - License Information:
443-
```
443+
```c
444444
/*
445445
* Copyright (C) 2013, 2014 INRIA
446446
* 2015 Freie Universität Berlin
@@ -453,7 +453,7 @@ Old Style - License Information:
453453
```
454454

455455
New Style - SPDX Format:
456-
```
456+
```c
457457
/*
458458
* SPDX-FileCopyrightText: 2013-2014 INRIA
459459
* SPDX-FileCopyrightText: 2015 Freie Universität Berlin
@@ -515,7 +515,7 @@ not a string literal`.
515515
possibility to suppress this warning/error. You MUST do so by adding a
516516
comment, including a rationale why it is a false positive and why the code
517517
can't be fixed otherwise, in the following format:
518-
```
518+
```c
519519
/* cppcheck-suppress <category of error/warning>
520520
* (reason: cppcheck is being really silly. this is certainly not a
521521
* null-pointer dereference */

0 commit comments

Comments
 (0)