Difference between revisions of "MansOS Coding Standard"

From DiLab
Jump to: navigation, search
Line 8: Line 8:


== variables ==
== variables ==
- variable names and function names should be written in camelcase(http://en.wikipedia.org/wiki/Camelcase) - writeByte, not write_byte, wrt_byte or WrItEbYtE.
variable names and function names should be written in camelcase(http://en.wikipedia.org/wiki/Camelcase) - writeByte, not write_byte, wrt_byte or WrItEbYtE.


int writeByte;
int writeByte;
void printByte(void *buf);
void printByte(void *buf);


- pointer variables with "_p" appended
=== pointer variables ===
with "_p" appended


int writeByte;
int writeByte;
Line 19: Line 20:




- constants and defines in all uppercase
=== constants and defines ===
in all uppercase
#define MAX_LENGTH 15
#define MAX_LENGTH 15
#define HEIGHT 7
#define HEIGHT 7


- enums, structs and all other type names with "_t" appended
=== enums, structs and all other types ===
variable names with "_t" appended


typedef
typedef

Revision as of 18:42, 2 April 2008

Indenting

Indent - 4 space Tab char - 8 space

if,for,while

if (...) { }

variables

variable names and function names should be written in camelcase(http://en.wikipedia.org/wiki/Camelcase) - writeByte, not write_byte, wrt_byte or WrItEbYtE.

int writeByte; void printByte(void *buf);

pointer variables

with "_p" appended

int writeByte; int writeByte_p; <-- like this


constants and defines

in all uppercase

  1. define MAX_LENGTH 15
  2. define HEIGHT 7

enums, structs and all other types

variable names with "_t" appended

typedef struct { int a; int b; int c; } MyStruct_t

typedef enum {RECTANGLE, CIRCLE} shapeType_t;