Coding-conventions

Version 3 (Anthony Rowe, 06/29/2007 03:23 am)

1 1 Anthony Rowe
2 1 Anthony Rowe
3 3 Anthony Rowe
h1. Nano-RK Coding Conventions
4 1 Anthony Rowe
5 1 Anthony Rowe
6 3 Anthony Rowe
7 3 Anthony Rowe
* private functions shall start with _
8 3 Anthony Rowe
* prefix nrk_ or _nrk_ before any Nano-RK related functions or data types
9 3 Anthony Rowe
* defines and constants will have NRK_ prefixed
10 3 Anthony Rowe
* all lower case separated by _ for functions
11 3 Anthony Rowe
* try to avoid abrv.
12 3 Anthony Rowe
* all types end with _t
13 3 Anthony Rowe
* byte order is little endian
14 3 Anthony Rowe
* Use C99 types: 
15 3 Anthony Rowe
16 3 Anthony Rowe
<pre>
17 1 Anthony Rowe
	#include <stdint.h>
18 1 Anthony Rowe
	#include <stdbool.h>
19 1 Anthony Rowe
        bool		// boolean
20 1 Anthony Rowe
	int8_t		
21 1 Anthony Rowe
	int16_t
22 1 Anthony Rowe
	int32_t		// signed int
23 1 Anthony Rowe
	int64_t
24 1 Anthony Rowe
25 1 Anthony Rowe
	uint8_t		// as a "BYTE" value	
26 1 Anthony Rowe
	uint16_t
27 1 Anthony Rowe
	uint32_t	// unsigned int
28 1 Anthony Rowe
	uint64_t
29 1 Anthony Rowe
	
30 1 Anthony Rowe
	float		// at the mercy of the compiler no hardware support
31 1 Anthony Rowe
	double		// at the mercy of the compiler no hardware support
32 1 Anthony Rowe
	
33 1 Anthony Rowe
	void*		// instead of char* 
34 1 Anthony Rowe
	char		// for text characters
35 3 Anthony Rowe
</pre>
36 1 Anthony Rowe
37 1 Anthony Rowe
38 3 Anthony Rowe
* use the following gnu INDENT options:
39 3 Anthony Rowe
** indent -br -brs -nut -npsl -i2 source_name.c
40 3 Anthony Rowe
* indent each level 2 more spaces than previous 
41 3 Anthony Rowe
* Don't put else on the same line of if
42 1 Anthony Rowe
 
43 3 Anthony Rowe
<pre>
44 1 Anthony Rowe
if (condition) foo (); else bar ();	/* Yuck! */
45 3 Anthony Rowe
</pre>
46 1 Anthony Rowe
47 3 Anthony Rowe
* Have the most significant description in a name first
48 3 Anthony Rowe
**  For example: nrk_led_clr() and not nrk_clr_led()