Вы находитесь на странице: 1из 4

Brief Abilis C Coding Guidelines

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

\brief Brief file explanation...

Long file explanation bla bla bla...

Bullets:
\li first
\li second

\todo Fix problem...

*/
 Function descriptions
/**
This function bla bla bla...

\param pOutput pointer to output...


\return returns TRUE on success, FLASE otherwise
*/
bool_te MyFct(void pOutput)
 Struct descriptions
/**
This structure...
*/
typedef struct
{
uint8_t ui8FirstMemeber, /** First member */
uint16_t ui16SecondMember /** Second member */
}mystruct_ts;

External links
 http://www.stack.nl/~dimitri/doxygen/commands.html

Вам также может понравиться