« Previous - Version 2/3 (diff) - Next » - Current version
Anthony Rowe, 06/29/2007 03:23 am


= Nano-RK Coding Conventions =

  • private functions shall start with _
  • prefix nrk_ or nrk before any Nano-RK related functions or data types
  • defines and constants will have NRK_ prefixed
  • all lower case separated by _ for functions
  • try to avoid abrv.
  • all types end with _t
  • byte order is little endian
  • Use C99 types:

{{{
#include <stdint.h>
#include <stdbool.h>
bool // boolean
int8_t
int16_t
int32_t // signed int
int64_t

uint8_t        // as a "BYTE" value    
uint16_t
uint32_t // unsigned int
uint64_t
float        // at the mercy of the compiler no hardware support
double // at the mercy of the compiler no hardware support
void*        // instead of char* 
char // for text characters
}}}
  • use the following gnu INDENT options: * indent -br -brs -nut -npsl -i2 source_name.c
  • indent each level 2 more spaces than previous
  • Don't put else on the same line of if

{{{
if (condition) foo (); else bar (); /* Yuck! */
}}}

  • Have the most significant description in a name first * For example: nrk_led_clr() and not nrk_clr_led()