----------------------------------------------------------------------- Pre Make Kit coding style file Document revision: # $Id: style.txt 1410 2005-05-14 11:37:38Z mipsator $ ----------------------------------------------------------------------- RECOMMENDED CODING STYLE FOR PMK -------------------------------- 1) Comments Comments in the code are GREATLY appreciated. /* simple in-code comment */ /* Recommended multiline comment. Other formats are allowed. */ The following is our "standard" fonction header that every new function should have : /******************* * function_name() * *********************************************************************** DESCR The description of the function processus IN arg1 : brief description of the named argument arg2 : same as above ... OUT description of what is returned ***********************************************************************/ 2) Includes #include #include "local_after.h" Each group of include can be sorted in alphabetical order. 3) Prototypes Use of tab indenting is recommended. Extra space to line up functions could be nice. void first_proc(void *); char *second_proc(char, int); int third_proc(char *); 4) Structures It uses the same specs as above, see the following example: struct mystruct { char *first_field; int second_field; double third_field; }; 5) Variables Always the same format: FILE *first_var; int second_var; char third_var[NB_CHAR], *fourth_var; Variables could be sorted by type in alphabetical order. You can also group them by letter case with uppercase first. 6) Keywords Keywords should be followed by a space instead of functions. 7) Functions Function must be declared on one line with type, function name, arguments and open brace as the following : int first_proc(char *arg_one, int arg_two) { Variables declared in functions respect the same rules defined in the fifth section. 8) Error messages When using the errorf() function, the format should look like the following: errorf("error message starting with a lowercase."); or errorf("error message %s : %s.", var, strerror(errno)); You should always use strerror(errno) when possible. Note that error messages always end with a dot (.) and start with a lowercase. 9) Exit statements - exit(EXIT_FAILURE) and exit(EXIT_SUCCESS) should be used respectively instead of exit(1) and exit(0).