Академический Документы
Профессиональный Документы
Культура Документы
Date 21.5.2007
Author Kristian Jorgensen
The present memo gives a brief overview of how the Abilis C coding standard. Any new
code should follow these guidelines.
Variables
Prefixes
p : pointer
a : array
i8/i16/i32/i64 : intergers
u : usigned
sz : Null terminated string
c : char
f : float
is : boolean
x : Extra typedef
Example:
mystruct_ts *pxMyStructPointer
Suffixes
_g : global variables
_ts : typedef structs
_te : typedef enums
Format
3 spaces for tabs
maximum 80 characters per lines
{ } scopes vertically aligned, example
if(isOK)
{
return TRUE;
}
else
{
return FALSE;
}
Names of variables varying case in stead of using “_” (underscore), example.
uint16_t ui16MyArrayIndexVar
All defines in uppercase and enclosed by parenthesis if containing operators,
example
#define MY_MAGICAL_SUM (a+b)
C restrictions
No use of “?:” operator
No magical numbers, all numbers other than 0 and 1 must come from a
#define
Debug macros
All functions except those called too frequently should have ENTER/LEAVE macros.
ENTER(string);
LEAVE();
INFO(string)
ASSERT(condition,string)
Comments
Doxygen comments applied
File descriptions
/**
\file
Bullets:
\li first
\li second
*/
Function descriptions
/**
This function bla bla bla...
External links
http://www.stack.nl/~dimitri/doxygen/commands.html