For those who coded in C++ before but not in "bare" C
C does not have the following things:
- classes
- templates
- overloading (both functions and operators)
- references
BAD
Code: Select all
const char *foo = "bar";Code: Select all
#define FOO "bar"The ioquake3 wiki can give you an idea on things, e.g. how the execution proceeds from the moment of launching the game.
For access to the source code repository, check out the SourceForge project page - there's a link to the left that says "SVN repository access" (or you can go directly to ViewVC if you only want to browse the code).
Coding style
This section contains coding style guidelines that I'm asking of you to obey (mostly copied over from the FreeCNC website). Mind you these are guidelines - I can take any code as long as it's clean and organized.
General presentation
- Comment all code that isn't self-explanatory. Especially that pointer hacking.
- Tab indenting, no four-spaces.
- Header guards follows the FILENAME_EXT convention - G_FOOBAR_H for game/g_foobar.h
- Indent #ifdef/#ifndef etc the same as regular code. That is, like normal if/else statements.
- When declaring pointers, put * next to the variable, not the type.
Code: Select all
int x = 42; int *z = &x; - Where applicable, start the file with a comment explaining the contents. For headers, place it right after the header guards.
Code: Select all
// g_script.c - implements the server side scripting - For big files, seperate sparingly with headers or simple splitters.
Code: Select all
//-------------------------------------------------------- // Script stack //--------------------------------------------------------Code: Select all
void foo (int bar) {return 0;} //-------------------------------------------------------- int bar (byte foo) {return foo & 0xdeadbeef;} - In cases where it makes sense, try to keep 80 chars per line.
- C++ style comments should be used for 1 liners. Never use /**/ for single line comments.
- Use ALL_UPPER_CASE for defines, enums values and macros.
Code: Select all
#define VERSION "0.3.0" enum { RED, GREEN, BLUE }; - Use Pascal casing or underscoring for words in variables.
Code: Select all
int fooBar; int foo_bar; - Use curly braces for control-flow statements that span several statements, and no braces for those comprised of one.
BADBADCode: Select all
if (true) printf("foo\n");GOODCode: Select all
if (true) { printf("foo\n"); }GOODCode: Select all
if (true) printf("foo\n");Code: Select all
if (true) { printf("foo\n"); printf("bar\n"); }



