Coding Style Guide ================== Line lengths Try to keep lines less than 80 characters. Break lines after logical separators Vertically align like constructs Indents Place function definition { in column 1 Place function definition } in column 1 Intent nested constructs by 2 characters void func() { stmt if (expr) stmt2 } Tabs Use only 8 column tabs Layouts if (expr) statement // If expr and statement are brief if (expr) statement if (expr1) { } else { } // If expression must be wrapped // align like constructs vertically if (expr1 && expr2)) { } while (expr) { } for (expr; expr; expr) { } typedef struct { } TYPENAME; Variable definitions Define one per line INT a; INT b; not INT a,b; Spaces Separate keywords from leading paren with 1 space if (expr) dothis No space between function name and leading paren No space between last arg and trailing paren func() Follow separating commas and semicolons with a space x = func(a, c) Surround binary operators with a leading and trailing spaces x = a + b Try to avoid spurious internal and trailing whitespace Memory - Check all malloc/realloc/strdup/DosAllocMem calls Use xmalloc in non-time critical code Use xrealloc in non-time critical code Use xstrdup in non-time critical code - Use xfree rather than free Windows - Check all WinCreateWindow calls - Check QWL_USER pointer data Error notifications DosBeep(50,100) Alert user to operator error Use only when failure reason is obvious saymsg Alert user to operator error with popup Runtime_Error Report "should not occur" errors Dos_Error Win_Error $Id: CodingStyle.txt 459 2006-08-24 05:10:24Z root $