Changes between Version 11 and Version 12 of Coding_Conventions
- Timestamp:
- Feb 3, 2012, 12:15:13 AM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v11 v12 18 18 * All source files (.cpp, .h) must start with the following GPL license header, before any other content: 19 19 {{{ 20 #!cpp 20 21 /* Copyright (C) 2012 Wildfire Games. 21 22 * This file is part of 0 A.D. … … 39 40 ''Exception:'' Code in `source/lib/` (and a few other files) should use the MIT license instead: 40 41 {{{ 42 #!cpp 41 43 /* Copyright (c) 2012 Wildfire Games 42 44 * … … 64 66 * Wrap header files in include guards, using the name `INCLUDED_`''filename'', e.g. the file `Foo.h` should say: 65 67 {{{ 68 #!cpp 66 69 #ifndef INCLUDED_FOO 67 70 #define INCLUDED_FOO … … 82 85 * Indent braces and use whitespace like 83 86 {{{ 87 #!cpp 84 88 int CExampleObject::DoSomething(int value) 85 89 { … … 102 106 * Write switch statements like 103 107 {{{ 108 #!cpp 104 109 switch (n) 105 110 { … … 133 138 * For error cases that could be triggered by modders (e.g. invalid data files), use 134 139 {{{ 140 #!cpp 135 141 LOGERROR(L"Failed to load item %d from file %ls", i, path.c_str()); 136 142 }}} … … 144 150 * Use [http://www.doxygen.org/ Doxygen] comments (explained [http://www.stack.nl/~dimitri/doxygen/docblocks.html here] as !JavaDoc style), e.g. 145 151 {{{ 152 #!cpp 146 153 /** 147 154 * A dull object for demonstrating comment syntax. … … 176 183 * For portability, use the following formats for printf-style functions: 177 184 {{{ 185 #!cpp 178 186 printf("%s", "char string"); 179 187 printf("%ls", L"wchar_t string"); … … 213 221 * Use quotes around the key names in object literals: 214 222 {{{ 223 #!js 215 224 var x = 100, y = 200; 216 225 var pos = { "x": x, "y": y }; … … 223 232 * To convert a string to a number, use the "`+`" prefix operator (not e.g. `parseInt`/`parseFloat`): 224 233 {{{ 234 #!js 225 235 var a = "1"; 226 236 var b = a + 1; // string concatenation; b == "11"