blob: 2bad092739c4c06820b42a154916d482ccf201fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
Author: Dodji Seketeli.
-----------------------
Introduction
------------
The coding standard we use are based on the GNU coding standards
available at http://www.gnu.org/prep/standards_toc.html
and on the Gnome Coding standards available at
http://developer.gnome.org/doc/guides/programming-guidelines/book1.html .
Please, make sure you read these documents before you read this one.
I) General coding style rules
---------------------------
Coding style refers to the way the code is formated.
Here are the guidelines we use in this project:
Indentation Style
- - - - - - - - - -
We use the 2-spaces tab indentation style (the GNU's one) .
Make sure as much as possible that each code line does not
exceed 80 characters length. Why ? because you don't know
who will read your code. The smallest screens are 80 chars
wide. So, please, make the code available to everybody.
Functions naming
- - - - - - - -
We use the GNU name scheme to name our functions.
GOOD:
int
my_function_name (char a_variable_name)
{
printf ("The variable value is %c", a_variable_name) ;
return 0 ;
}
BAD:
int
myFunctionName (char blabla)
{
printf ("This is awfull\n") ;
}
or
int my_FunctionName (char Blabla) {
printf ("This is bad\n") ;
}
The words of the function names are separared by an underscore ('_') and
are written in lower case.
The name functions arguments allways start with by a "a_" .
Avoid for instance the Java function (method) name scheme by mixing
upper and lower case in the function names.
Be genereous with white spaces:
GOOD:
int foo (int a_parameter)
{
if (test == TRUE) {
printf ("Coucou\n") ;
}
}
BAD:
int foo(int a_parameter)
{
if(test==TRUE) {
printf("coucou\n")
}
}
To ensure that the each line of code is less than 80 characters,
if a function has many parameters, you can write it this way:
Constants naming
- - - - - - - - -
Constants (defines or constant variables) must be in upper case.
The worlds of the constant name must be separated by an underscore ('_').
For instance:
GOOD:
gint A_CONSTANT = 10 ;
#define ANOTHER_CONSTANT 100 ;
BAD:
gin a_Constant = 10 ;
#define another_Constant ;
structure and enum naming
---------------------
II) Object Oriented C programming
-----------------------------
|