blob: c3dc10e42798f8df1189b9a505c3ef2bb5535184 (
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
|
============
Coding Style
============
- Use explicit ``!= NULL``, ``!= 0``, etc. This makes code easier to read
and remove warnings on some platform. Don't forget SPACES before and
after the comparison operator.
Examples:
BAD:
``if(a)``
BAD:
``if(a!=NULL)``
GOOD:
``if(a != NULL)``
GOOD:
``if(a != 0)``
- Put figure brackets ``{}`` even if you have only one operator
in ``if``, ``for``, etc. This also makes code easier to read and
saves a lot of time when you need to quickly change something.
Examples:
BAD:
.. line-block::
if(a != NULL)
message(G_LOG_LEVEL_MESSAGE, "Ko");
GOOD:
.. line-block::
if(a != NULL) {
message(G_LOG_LEVEL_MESSAGE, "Ok");
}
- Use round brackets ``()`` for ``return``.
Examples:
BAD:
``return 0;``
GOOD:
``return(0);``
- Check for memory leaks.
|