Coding-conventions

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

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