[doxygen] Updated code style guide

* added example for if/else
* added Eclipse code style
* syncronized all examples with the guide
This commit is contained in:
podhrmic
2014-01-05 17:23:50 -08:00
parent b9fac2e710
commit 4221260fdb
+27 -7
View File
@@ -22,7 +22,9 @@ Feedback would be welcome to improve the Paparazzi guidelines.
/** @page stylec C Style Guide
This page contains guidelines for writing new C source code for the
Paparazzi project.
Paparazzi project. If you are using Eclipse, download Paparazzi code
style for Eclipse here:
http://paparazzi.enac.fr/wiki/File:Paparazzi_code_profile_eclipse.zip
@section styleformat Formatting Guide
@@ -58,8 +60,7 @@ static inline int cube(int x) { return x * x * x; }
- define static functions before first usage to avoid forward declarations.
- Functions should have no space between its name and its parameter list:
@code
int32_t f(int32_t x1, int32_t x2)
{
int32_t f(int32_t x1, int32_t x2) {
...
int32_t y = f(x1, x2 - x1);
...
@@ -71,14 +72,12 @@ int32_t f(int32_t x1, int32_t x2)
- specify a default case
- prefer an enum over defines for the different states
@code
enum state
{
enum state {
STATE_FOO = 1,
STATE_BAR = 2
};
switch( state )
{
switch (state) {
case STATE_FOO:
foo();
break;
@@ -90,6 +89,27 @@ switch( state )
}
@endcode
@section styleif If statements
- return statement on the new line even for ""simple if"" case
@code
if (TRUE) {
return 1;
}
if (x < other.x) {
return -1;
}
else if (x > other.x) {
return 1;
}
else {
return 0;
}
@endcode
@section stylecpp Preprocessor directives
- For conditional compilation use @c \#if instead of @c \#ifdef.
Someone might write code like: