Skip to main content

Coding Guidelines


When submitting patches or otherwise adding code to the project please follow some basic coding guidelines.
Most .c files will have this information at the very end for your reference:

/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4

Click here to expand Table of Contents

Structures and Curly Braces

Please observe these conventions:

  • Tabs are preferred over spaces, tab-width is four characters
  • Always use curly braces for conditional statements *unless* they are on the same line and are very short
  if (foo) printf("blah\n");
  • Always space after if
if (foo) {

  • Nested else
if (foo) {
} else if (bar) {

} else {

  • Function definitions with newline
int foo (int arg)


Please use comments appropriate to the language you are using.


Use /* and */ when adding comments in C programs. Please don't use // for comments in C programs.


Use the // style for C++ programs


Lua has two styles of comments:

  • Single Lines
-- This is a single line comment
  • Multiple Lines
All of this
Is commented