Files
HomeworldSDL/documentation/coding_standards.txt
lmop c632f57ae4 Sticking my oar in :)
git-svn-id: svn://www.homeworldsdl.org:3692/homeworldsdl/homeworld/trunk@415 026c9d8a-83c9-0310-a9c7-971d0a006279
2006-12-12 21:44:17 +00:00

47 lines
2.0 KiB
Plaintext

----------------------------------------------------------------------
Coding standards that should be applied to the HWSDL codebase.
----------------------------------------------------------------------
Homeworld SDL is and should remain C-compliant. No C++ classes etc please. The only exception is the use of the C++ single-line notation:
// comment
which is allowed by all modern C compilers.
----------------------------------------------------------------------
Indentation
----------------------------------------------------------------------
Each indentation increment should indent 4 spaces. No tab characters.
----------------------------------------------------------------------
Bracing
----------------------------------------------------------------------
It isn't always the case but the vast majority of the Homeworld source code uses vertically aligned bracing, so use the same for consistency:
if (condition)
{
action;
}
Although allowed by the C language definition and used in the code, do NOT use single statement if() notation. The above could be written:
if (condition)
action;
Don't. Brace it up to prevent confusion/bugs.
----------------------------------------------------------------------
#defines
----------------------------------------------------------------------
#define constant names should be UPPERCASE.
Some common #defines to note:
PATH_MAX => buffer size for file path strings
<platform>_FIX_ME => #if'd to indicate that something is broken on <platform> which needs to be addressed at a later date
----------------------------------------------------------------------
variable/function naming
----------------------------------------------------------------------
All variable/function names should start with a lowercase letter. (Uppercase is indicative of Classes or #defines.) camelCaseNotation is used by a lot of code although underscore_word_separated is not uncommon either. Please use the predominant style used in the file you are editing.